获得用户宗教和兴趣facebook

时间:2013-06-26 23:50:15

标签: php facebook

我不断收到“Undefined index:interests”&&当我运行我的facebook登录代码时,“Undefined index:religion”。一切看起来都合适。我检查过并重新检查。我不知道问题是什么。

  try{
    $uid = $session;
    $user = $facebook->api('/me');
    $userLikes = $facebook->api('/me/likes');
} catch (Exception $e){}
if(!empty($user)){
    # We have an active session, let's check if we have already registered the                  user
    $query = mysql_query("SELECT * FROM users WHERE oauth_provider = 'facebook'    AND oauth_uid = ". $user['id']);
    $result = mysql_fetch_array($query);

    # If not, let's add it to the database
    if(empty($result)){
        $location = serialize($user['location']); 
        $interestedIn = serialize($user['interested_in']); 
        $interests = serialize($userLikes['interests']); 
        $query = mysql_query("INSERT INTO users    (name,email,gender,birthday,local,location,religion,political,interestedIn,interests,oauth_provider, oauth_uid, link) 
        VALUES     ('{$user['name']}','{$user['email']}','{$user['gender']}','{$user['birthday']}','{$user['locale']}','$location','{$user['religion']}','{$user['political']}','$interestedIn','$interests','facebook', {$user['id']}, '{$user['link']}')");
        $query = mysql_query("SELECT * FROM users WHERE id = " .     mysql_insert_id());
        $result = mysql_fetch_array($query);
    }

权限

  $loginUrl = $facebook->getLoginUrl(array(
            'scope'         => 'email,offline_access,publish_stream,user_birthday,user_location,user_about_me,user_hometown,user_relationship_details,user_religion_politics,user_relationships,user_likes,user_checkins,user_interests',

        ));

0 个答案:

没有答案