2013-02-06 89 views
0

我想看看是否已授予權限的用戶喜歡指定的FB頁面。問題是,它總是返回true,即使頁面不被喜歡。代碼如下:Facebook的FQL爲喜歡總是返回真

public function verifyFbLike($userId, $objectId) 
    { 
     $appID = 'XXX'; 
     $clientSecret = 'XXX'; 
     $url = 'https://graph.facebook.com/oauth/access_token?client_id=' . $appID . '&client_secret=' . $clientSecret . '&grant_type=client_credentials'; 
     $accessToken = file_get_contents($url); 
     $accessToken = str_replace('access_token=', '', $accessToken); 

     $query = urlencode('SELECT user_id FROM like WHERE object_id="' . $objectId . '"'); 
     $xml = file_get_contents('https://api.facebook.com/method/fql.query?query=' . $query . '&access_token=' . $accessToken); 
     $xmlObj = new SimpleXMLElement($xml); 

     // See if user did like the object or not 
     if($xmlObj->attributes()->list == 'true') 
      return TRUE; 
     else 
      return FALSE; 
} 

回答

0

將urlencode(...)更改爲rawurlencode(...)修復它。

相關問題