开发者

inserting facebook app users details to database

i'm trying to insert user details, who authorize the app, into the database, but nothing seems to be happening. the data is null and no record is being inserted. is there something wrong with the code?

function insertUser($user_id,$sk,$conn)
{

    //$info = $facebook->api_client->users_getInfo($user_id, 'first_name, last_name', 'name', 'sex');
    $info = $facebook->api_client->fql_query("SELECT uid, first_name, last_name, name, sex FROM user WHERE uid = $user_id");

    for ($i=0; $i < count($info); $i++) {
    $record = $info[$i]; 
    $first_name=$record['first_name'];
    $last_name=$record['last_name'];
    $full_name=$record['name'];
    $gender=$record['sex'];

    }

    $data= mysql_query("select uid from users where uid='{$user_id}'",$conn);
    if(mysql_num_rows($data)==0)
    {
        $sql = "INSERT INTO users (uid,sessionkey, active, fname, lname, full_name, gender) VALUES('{$user_id}','{$sk}','开发者_运维技巧1', '{$first_name}', '{$last_name}', '{$full_name}', '{$gender}')";
        mysql_query($sql,$conn);
        return true;
    }
    return false;
}


called the install code manually, rather than leave it upon facebook to ping the url.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜