4

我需要在 CRONJOB 中运行一个查询来检查 2 个 FBuser 是否是共同的朋友:类似于以下内容,但我收到此错误:

Warning: file_get_contents(https://graph.facebook.com/fql?q=SELECT......) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad  Request in...

在 FBtool 我收到以下错误:

{
 "error": {
"message": "(#601) Parser error: unexpected '+' at position 6.",
"type": "OAuthException",
"code": 601
 }
 } )

这是脚本:

// get App AccessToken
$app_token_url = "https://graph.facebook.com/oauth/access_token?"
 . "client_id=" . $appId
 . "&client_secret=" .$secret
 . "&grant_type=client_credentials";

    $response = file_get_contents($app_token_url);
    $params = null;
    parse_str($response, $params);

  $App_access_token = $params['access_token'];

try { $permissions = $facebook->api('/'.$user1.'/permissions');
            } catch(Exception $o){  $log[] = "//***  error on   $user1/permissions > $o";   }
$permessi=$permissions[data][0];

if(array_key_exists('read_stream', $permessi) or array_key_exists('read_friendlists', $permessi) ) {

$fql_q = "SELECT 'uid1','uid2' FROM friend WHERE 'uid1'='$user1' AND 'uid2'='$user2'"; 
$fql_q = urlencode($fql_q); 
$fql_query_url = "https://graph.facebook.com"
  ."/fql?q=$fql_q"
  ."&access_token=$App_access_token";
 $fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);
if(is_array($fql_query_obj)){ 
$CountFriends = $CountFriends + 1;
}    
4

2 回答 2

1

Facebook 离线访问已被弃用 请点击此链接: offline-access-removal

于 2013-01-18T13:21:53.190 回答
0

这里的解决方案

https://developers.facebook.com/docs/graph-api/reference/v2.0/user/friends#readmodifiers

我希望能有所帮助谢谢

于 2014-07-23T07:43:02.947 回答