我正在使用的代码:
$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());
Output:这仅表明:无法从签名请求中获取 OAuth 数据。用户尚未授权您的应用
我正在使用我的页面app_id and app_secret
.
您使用的示例“(...)涵盖从应用程序画布的上下文中获取访问令牌和签名请求(...)”。https://developers.facebook.com/docs/php/howto/example_access_token_from_canvas https://developers.facebook.com/docs/php/howto/example_access_token_from_canvas
应用程序画布的上下文意味着您的应用程序嵌入在 Facebook (iframe) 上。https://stackoverflow.com/a/41669757/2911960 https://stackoverflow.com/a/41669757/2911960
我假设您想在您的网站上使用 API。那么你正在寻找这个:https://developers.facebook.com/docs/php/howto/example_facebook_login https://developers.facebook.com/docs/php/howto/example_facebook_login
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)