所以我使用facebook-php-sdk並創建了一個頁面標籤 在頁面選項卡上,我嘗試使用SDK,它只在我登錄Facebook時才起作用不作爲用戶,那麼這是什麼原因呢?Facebook-php-sdk
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中:錯誤簽名JSON簽名
定義「只有作品」。什麼是不工作時的輸出? –
我得到空值,但是當它得到我使用的頁面配置文件。 – Aaron
錯誤的APP ID和/或密鑰? – 2012-08-23 03:30:19