[英]Facebook getuser return 500 internal error in PHP SDK
我遇到這種類型的問題,我使用最新版本的PHP SDK,並且從3月開始,當我必須完成登錄時,我的應用程序停止了。 我已經上傳了最新版本,但是現在當php執行時
$user = $facebook->getUser();
我收到錯誤500內部等。 我已經嘗試了所有方法,但是現在我不知道出了什么問題,我也嘗試了使用Facebook PHP SDK 500-內部服務器錯誤
但我只獲得內部錯誤。 如果有人可以幫助我。 代碼是這個
<?php
require 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'fdsafdasfdasfdsafas8',
'secret' => 'dasgasgasgasgas',
));
// See if there is a user from a cookie
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
$user = null;
}
}
?>
<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<body>
<?php if ($user) { ?>
Your user profile is
<pre>
<?php print htmlspecialchars(print_r($user_profile, true)) ?>
</pre>
<?php } else { ?>
<fb:login-button></fb:login-button>
<?php } ?>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '<?php echo $facebook->getAppID() ?>',
cookie: true,
xfbml: true,
oauth: true
});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
FB.Event.subscribe('auth.logout', function(response) {
window.location.reload();
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
</body>
</html>
您可能需要啟用ssl庫,也可以檢查Apache日志中的錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.