我使用的代码:
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.6',
]);
$helper = $fb->getCanvasHelper();
try {
$accessToken = $helper->getAccessToken();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
if (! isset($accessToken)) {
echo 'No OAuth data could be obtained from the signed request. A user has not authorized your app yet.';
exit;
}
// Logged in
echo '<h3>Signed Request</h3>';
var_dump($helper->getSignedRequest());
echo '<h3>Access Token</h3>';
var_dump($accessToken->getValue());输出:--这只表明:无法从已签名的请求中获取OAuth数据。用户尚未授权您的应用程序。
我正在使用我的页面的app_id and app_secret。
发布于 2019-08-08 08:39:30
您使用的示例“(.)包括从应用画布(.)的上下文中获取访问令牌和签名请求”。canvas
应用画布的上下文意味着您的应用程序嵌入到Facebook (iframe)上。https://stackoverflow.com/a/41669757/2911960
我想你想要在你的网站上使用API。那么你要找的是:login
https://stackoverflow.com/questions/40882664
复制相似问题