Facebook Graph API GET http请求,php

Luc*_*ord 2 php json facebook facebook-graph-api

我正在尝试制作图表API GET请求.它适用于Graph API资源管理器,但我似乎无法让应用程序自己调用它.

我正在尝试检索用户对象中的共同朋友.请参阅文档:https: //developers.facebook.com/docs/reference/api/user/

    <?php

        $mutual = json_decode(file_get_contents("https://graph.facebook.com/".$fb_id."?".$access_token."/mutualfriends/".$other_fb_id));

    ?>
Run Code Online (Sandbox Code Playgroud)

但这似乎并没有起作用.

Jui*_*ter 7

你混合URL参数path,它应该是这样的(?access_token=...部分应该放在最后):

$url = "https://graph.facebook.com/{$fb_id}/mutualfriends/{$other_fb_id}";
$url_with_token = $url . "?access_token={$access_token}";
$mutual = json_decode(file_get_contents($url_with_token));
Run Code Online (Sandbox Code Playgroud)