此方法不適用於您。您最好使用JavaScript來處理登錄和身份驗證。
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID',
session : { VALID_SESSION_DATA }, // don't refetch the session if PHP already has it
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
function login() {
FB.login(
function(response) {
if (response.session) {
if (response.perms) {
// user is logged in, and granted any permissions
} else {
// user is logged in, but did not grant any permissions
}
} else {
// user is not logged in
}
}, {perms:'publish_stream'}
);
}
</script>
你可以粘貼一個你如何授權用戶的代碼示例嗎? – jBit
是的,在這裏:$ logoutUrl = $ facebook - > getLoginUrl(); \t echo(「」); – user310707
您使用的是什麼版本的PHP SDK? – jBit