0

我正在尝试查看已授予权限的用户是否喜欢指定的 FB 页面。问题是,它总是返回 true,即使页面没有被喜欢。这是代码:

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;
}
4

1 回答 1

0

将 urlencode(...) 更改为 rawurlencode(...) 修复了它。

于 2013-02-12T06:51:43.170 回答