我有 facebook 应用程序,我使用 php CURL 进行授权并获取访问令牌和 facebook 用户 ID。我有以下代码允许用户访问:
function AlowUserAccess()
{
include "config.php";
error_reporting(0);
if($_REQUEST['code'])
{
$returnurl = $fbconfig['baseUrl'];
$url = "https://graph.facebook.com/oauth/access_token?client_id=".$fbconfig['appid']."&client_secret=".$fbconfig['secret']."&grant_type=fb_exchange_token&fb_exchange_token=".$_REQUEST['code'];
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_VERBOSE => true
));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
我打印了上述函数的返回值 $result 并返回以下错误:
{"error":{"message":"Malformed access token AQxxxxxxxxxGypoLOAjcig9qSai_MuNna8marHxuddddCno6T_NqqD19zzzzzzzGNy_FJbcK9heZKPCSysXBYHFTD_AgzMxwE5BqIEHvyK-QGl5kv1R0bPOUx7V0xs5-OQdsfddsRc0uoR_y1ElTlY4YCrWr5dfssdfsdfdsITrXezhcv1S_pu-3g0Kx8v-VtsvMI6oVYlC0J4eogSL6yhIsWrNS6uuTZIWwE0BGWJCjVieU-BbCPLsqkasdVFjnPz489xdb2_bSfVBKvsdfsdfaefYtn3luygCs","type":"OAuthException","code":190}}