Я просмотрел множество сообщений на сайте, но по-прежнему не смог получить доступ к Facebook и перенаправить работу. Когда пользователь входит в систему через Facebook, нажав кнопку на веб-странице, я хочу автоматически перенаправить их на другую веб-страницу и передать их адрес электронной почты и пароль через URL-адрес. К сожалению, мне только нужно, чтобы он работал до такой степени, что при входе в систему мне нужно вручную перезагрузить страницу, чтобы отправить их на страницу перенаправления, обновив мою веб-страницу. Мне было интересно, может ли кто-нибудь опубликовать код о том, как это сделать? Я пробовал много перемещать.Facebook Войти Redirect PHP/Javascript не работает
<?php
//uses the PHP SDK. Download from https://github.com/facebook/php-sdk
require 'facebook.php';
define('YOUR_APP_ID', 'xxxx');
$facebook = new Facebook(array(
'appId' => 'xxxx',
'secret' => 'xxxx',
));
?>
<div id="fb-root"></div>
<div id="user-info"></div>
<div class="fb-login-button" style="position:absolute;top:800px;">Login with Facebook</div>
<script>
window.fbAsyncInit = function() {
FB.init({ appId: 'xxxx',
status: true,
cookie: true,
xfbml: true,
oauth: true});
function updateButton(response) {
var button = document.getElementById('fb-auth');
if (response.authResponse) {
//user is already logged in and connected
var userInfo = document.getElementById('user-info');
FB.api('/me', function(response) {
userInfo.innerHTML = '<img src="https://graph.facebook.com/'
+ response.id + '/picture">' + response.email;
button.innerHTML = 'Logout';
});
button.onclick = function() {
FB.logout(function(response) {
var userInfo = document.getElementById('user-info');
userInfo.innerHTML="";
});
};
}
else {
//user is not connected to your app or logged out
button.innerHTML = 'Login';
button.onclick = function() {
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(response) {
var userInfo = document.getElementById('user-info');
userInfo.innerHTML =
'<img src="https://graph.facebook.com/'
+ response.id + '/picture" style="margin-right:5px"/>'
+ response.name;
});
} else {
//user cancelled login or did not grant authorization
}
}, {scope:'email'});
}
}
}
// run once with current status and whenever the status changes
FB.getLoginStatus(updateButton);
FB.Event.subscribe('auth.statusChange', updateButton);
};
(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>
<?php
$uid = $facebook->getUser();
if($uid != 0) {
header("Location: signup.php");
}
?>
спасибо за ответ, но он по-прежнему не будет автоматически перенаправлять пользователь. Мне нужно вручную обновить страницу, чтобы перейти на страницу переадресации. Вы знаете, как я могу заставить это работать автоматически? – user1446797