Php 正在尝试使用给定的访问令牌访问服务器端的facebook好友。OAutheException代码=>;2500错误

Php 正在尝试使用给定的访问令牌访问服务器端的facebook好友。OAutheException代码=>;2500错误,php,facebook-graph-api,facebook-access-token,Php,Facebook Graph Api,Facebook Access Token,我正在尝试使用访问令牌(客户端代码发送给我)检索服务器端用户的好友列表。我使用file_get_内容检索好友列表,并使用递归迭代器将其显示回屏幕。有人能指导我如何解决这个错误吗 $context = stream_context_create(array( 'http' => array( 'ignore_errors'=>true, 'method'=>'POST' ) )); $response = json_decode(file_get_co

我正在尝试使用访问令牌(客户端代码发送给我)检索服务器端用户的好友列表。我使用file_get_内容检索好友列表,并使用递归迭代器将其显示回屏幕。有人能指导我如何解决这个错误吗

$context = stream_context_create(array(
    'http' => array(
    'ignore_errors'=>true,
    'method'=>'POST'

)
));

$response = json_decode(file_get_contents("https://graph.facebook.com/me/friendsaccess_token=".$token, false, $context));


    $jsonIterator = new RecursiveIteratorIterator(
    new RecursiveArrayIterator($response, RecursiveIteratorIterator::SELF_FIRST));

    foreach ($jsonIterator as $key => $val) {
        if(is_array($val)) {
            echo "$key:\n";
        } else {
            echo "$key => $val\n";
    }
错误:

message => Unknown path components:/friendsaccess_token=<Access_Token>
type => OAuthException
code => 2500
message=>未知路径组件:/friendsaccess\u令牌=
类型=>OAutheException
代码=>2500

您需要在查询字符串中传递
访问令牌。因此,在
朋友
之后的URL请求中添加一个问号(

$response = json_decode(file_get_contents("https://graph.facebook.com/me/friends?access_token=".$token, false, $context));

从错误消息
未知路径组件:/friendsaccess\u token=
中可以明显看出,您正在获取响应的感谢。我现在得到了“message=>(#100)type=>OAutheException code=>100”。你能帮我解决这个问题吗?试着把方法从POST改为
GET
来解决这个问题?请标记答案并结束此问题。