Facebook-php-sdk
所以我使用 facebook-php-sdk 并且创建了一个页面选项卡 在页面选项卡上,我尝试使用 SDK,它仅在我以页面而非用户身份登录 facebook 时才有效,那么造成这种情况的原因是什么?
require 'facebook-php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => '//APP ID//',
'secret' => '//APP SECRET//',
));
// Get User ID
$user = $facebook->getUser();
// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
}
catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if(isset($user)) {
var_dump($user);
}
else if(isset($user_profile)) {
var_dump($user_profile);
}
else {
echo $loginUrl;
}
var_dump($facebook->getUser());
我得到的是 error_log: Bad Signed JSON 签名
So I am using the facebook-php-sdk and I have created a page tab
On the page tab I am trying to use the SDK and it only works when I have logged into facebook as the page not as a user so what would the cause of this be?
require 'facebook-php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => '//APP ID//',
'secret' => '//APP SECRET//',
));
// Get User ID
$user = $facebook->getUser();
// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
}
catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if(isset($user)) {
var_dump($user);
}
else if(isset($user_profile)) {
var_dump($user_profile);
}
else {
echo $loginUrl;
}
var_dump($facebook->getUser());
I get this is the error_log: Bad Signed JSON signature
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在测试的用户是否已连接到该页面(即,喜欢它)?否则,您将不会收到有关用户身份的任何信息。这是可以预料的。当用户没有明确喜欢该页面时,Facebook 会尽力匿名化用户与页面应用程序的交互。
Is the user you are testing with connected to the page (i.e., Liked it)? If not you will not receive any information about who the user is. This is to be expected. Facebook does its best to anonymize the user interaction with pages' apps when the user hasn't explicitly Liked the page.