如果两个FB用户是共同的朋友,如何离线检查

时间:2012-11-23 12:24:09

标签: facebook-fql

我需要在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;
}    

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)