Facebook:Returns";500(内部服务器错误)";朋友信息请求

Facebook:Returns";500(内部服务器错误)";朋友信息请求,facebook,facebook-graph-api,Facebook,Facebook Graph Api,我已在我和应用程序的“权限”页面上设置了以下权限: (注意“读取流”) 然而,对于用户的朋友来说,同样的方法是行不通的。 它给出一个“500(内部服务器错误)”,facebook对象返回“未知错误” 我已将问题追溯到我要求的领域。删除/me/friends返回数据时,部分状态.限制(1).字段(消息)似乎是错误的来源。 但我不明白错误的原因。 它适用于/me 根据FB文档read_steam应同时用于用户状态和用户朋友状态。 通过以上字段,API资源管理器可以无任何问题地获取好友状态。 我是

我已在我和应用程序的“权限”页面上设置了以下权限:
(注意“读取流”)


然而,对于用户的朋友来说,同样的方法是行不通的。
它给出一个“500(内部服务器错误)”,facebook对象返回“未知错误”



我已将问题追溯到我要求的领域。删除
/me/friends
返回数据时,部分
状态.限制(1).字段(消息)
似乎是错误的来源。
但我不明白错误的原因。

  • 它适用于
    /me

  • 根据FB文档
    read_steam
    应同时用于用户状态和用户朋友状态。
  • 通过以上字段,API资源管理器可以无任何问题地获取好友状态。
  • 我是做错了什么,还是FB Graph API错误?

    谢谢。

    在这里试试这个:

    $user = $facebook->getUser();
    if ($user){ 
               try {
                    $queries = array(
                                 array('method' => 'GET', 'relative_url' => '/'.$user),
                                 array('method' => 'GET', 'relative_url' => '/'.$user.'/friends', 'name' =>  'get-friends'),
                                 array('method' => 'GET','relative_url'  => '?ids={result=get-friends:$.data.*.id}'),
                                );
    
                                // POST your queries to the batch endpoint on the graph.
                                try{
                                    $batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST');
                                }catch(Exception $o){
                                        error_log($o);
                                }
                              } 
                            catch (FacebookApiException $e) {
                                error_log($e); //Checks if user is logged out and generate an exception if access token is invalid
                            }
                         }
                         else{
                                $params = array(
                                      'scope' => 'friends_birthday, friends_education_history, read_stream, read_friendlists, user_birthday,   //Requesting User Permissions through Facebook App
                                      'redirect_uri' => 'specify yours here' //User is redirected after Login
                                    );
    
                            } 
     $user_details = json_decode($batchResponse[0]['body'], true);// User Own Info
     $user_friends = json_decode($batchResponse[2]['body'], true);// User's Firend Info
    
    您将得到一个数组对象

    或者您也可以在此处使用FQL:

    $friends = $facebook->api(array(
                                            'method' => 'fql.query',
                                            'query' => 'SELECT name, pic_big 
                                                 FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())'
                                        ));
    

    我正在做类似的工作,这里:

    FB.api('/me/friends', {
                fields: "id,username,name,first_name,last_name,location,link,education,work,statuses.limit(1).fields(message)"
            }, function(res){
                console.log('FRIENDS', res.data);
            });
    
    $user = $facebook->getUser();
    if ($user){ 
               try {
                    $queries = array(
                                 array('method' => 'GET', 'relative_url' => '/'.$user),
                                 array('method' => 'GET', 'relative_url' => '/'.$user.'/friends', 'name' =>  'get-friends'),
                                 array('method' => 'GET','relative_url'  => '?ids={result=get-friends:$.data.*.id}'),
                                );
    
                                // POST your queries to the batch endpoint on the graph.
                                try{
                                    $batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST');
                                }catch(Exception $o){
                                        error_log($o);
                                }
                              } 
                            catch (FacebookApiException $e) {
                                error_log($e); //Checks if user is logged out and generate an exception if access token is invalid
                            }
                         }
                         else{
                                $params = array(
                                      'scope' => 'friends_birthday, friends_education_history, read_stream, read_friendlists, user_birthday,   //Requesting User Permissions through Facebook App
                                      'redirect_uri' => 'specify yours here' //User is redirected after Login
                                    );
    
                            } 
     $user_details = json_decode($batchResponse[0]['body'], true);// User Own Info
     $user_friends = json_decode($batchResponse[2]['body'], true);// User's Firend Info
    
    $friends = $facebook->api(array(
                                            'method' => 'fql.query',
                                            'query' => 'SELECT name, pic_big 
                                                 FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())'
                                        ));