我正在使用Facebook PHP SDK v 5.0,而我正试图让Facebook好友。 我使用以下代码:
$requestFriends = $fb->request('GET', '/me/friends?fields=id,name');
$batchFrineds = ['user-friends' => $requestFriends,];
$responsesFriends = $fb->sendBatchRequest($batchFrineds);
foreach ($responsesFriends as $key => $response)
{
//echo "Response: " . var_dump($response) . "</p>\n\n";
}
结果在这里:
[
{
"code":200,
"headers":[{"name":"Access-Control-Allow-Origin","value":"*"},
{"name":"ETag","value":"\"2339ed6ac11ca077990150e70a0b2b00c80710e9\""},
{"name":"Vary","value":"Accept-Encoding"},
{"name":"Pragma","value":"no-cache"},
{"name":"Cache-Control","value":"private, no-cache, no-store, must-revalidate"},
{"name":"Content-Type","value":"text\/javascript; charset=UTF-8"},
{"name":"Facebook-API-Version","value":"v2.0"},
{"name":"Expires","value":"Sat, 01 Jan 2000 00:00:00 GMT"}],
"body":
"{
\"data\":
[
{\"id\":\"100001258423346\",\"name\":\"\\u0414. \\u0410\\u043d\\u0430\\u0440\"},{\"id\":\"100001340034751\",\"name\":\"Jani BoLd\"},{\"id\":\"100001689146477\",\"name\":\"\\u0411. \\u041d\\u044f\\u043c\\u0441\\u04af\\u0440\\u044d\\u043d\"},{\"id\":\"100001734957601\",\"name\":\"\\u041d\\u0430\\u0440\\u0430\\u0430 \\u04e8\\u043b\\u0437\\u0438\\u0439\\u0441\\u0430\\u0439\\u0445\\u0430\\u043d\"},{\"id\":\"100002982584139\",\"name\":\"\\u0411. \\u041d\\u044f\\u043c\\u0441\\u04af\\u0440\\u044d\\u043d\"},{\"id\":\"100003030795256\",\"name\":\"\\u0425\\u0438\\u0448\\u0433\\u044d\\u044d \\u0418\\u0440\\u043c\\u04af\\u04af\\u043d\"},{\"id\":\"100003970992671\",\"name\":\"\\u0411\\u0430\\u0442 \\u041e\\u0440\\u0448\\u0438\\u0445\"},{\"id\":\"100005014861144\",\"name\":\"\\u0411. \\u0410\\u0431\\u0443\\u0443\"},{\"id\":\"100005092027529\",\"name\":\"Oyun Nyamaa\"}
],
\"paging\":
{\"next\":\"https:\\\/\\\/graph.facebook.com\\\/v2.0\\\/1635590113348375\\\/friends?fields=id,name&access_token=9cGq\"
},
\"summary\":
{
\"total_count\":406
}
}"
}
]
但我无法让朋友们完全依赖这个结果。