Я работаю с фреймворком javascript sdk. когда я делаю вызов api, он возвращается и вызывает функцию ошибки, однако возвращает данные, которые я запросил. Несмотря на то, что он возвращает правильные данные, я хотел бы знать, почему он выполняет функцию ошибки. Вы можете помочь? благодаряПочему мой вызов facebook graph api вызывает функцию обратного вызова ошибки
JavaScript:
window.fbAsyncInit = function() {
FB.init({
appId : '<my_App_id>',
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse social plugins on this page
version : 'v2.5' // use graph api version 2.5
});
//device APIs are available
document.getElementById("facebook_login").addEventListener('click', loginViaFacebook, false);
function loginViaFacebook(){
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//user is logged into our app and facebook.
//now we need to get their facebook email address and check if they are registered with us. ie their email address exists in the database
FB.api("me/?fields=id,email,picture", ["public_profile"],function(result){
alert("Result: " + JSON.stringify(result));
//do ajax request here with email address.
},
function(error){
//api call failed
alert("api call Failed: " + JSON.stringify(error));
}
);
}else if(response.status === 'not_authorized'){
//The person is logged into Facebook, but not your app.(facebook docs)
//in this case though they are coming from just pressing the facebook_login button on our app so we dont need to tell them to log in.
}else{
FB.login(function(response) {
// handle the response
console.log("UserInfo: " + response.authResponse.userID);
if(response.status === 'connected'){
FB.api('/me?fields=id, email, name, picture', ["public_profile"],function(data) {
console.log(data);
var fb_user_id = data.id;
var fb_name = data.name;
var fb_email = '[email protected]';
var fb_picture_url = data.picture.data.url;
facebook_details.push({'fb_name': fb_name, 'fb_pic': fb_picture_url});
console.log(fb_user_id);
$.ajax({
type: 'post',
url: 'http://www.example.com/login_with_facebook.php',
data: {'fb_user_id': fb_user_id, 'fb_email': fb_email},
success: function(data){
alert("data" + data);
},
error: function(xhr, status, error) {
alert("error message:" + error);
}
}); //end ajax
},
function(error){
//api call failed
alert("login api call Failed: " + JSON.stringify(error));
}); //end api call
}//end if statement
},
function(error){
alert("FB login Failed: " + error);
});
}
},
function(error){
alert("FB get status Failed: " + error);
});
}//end loginViaFacebook
};
//remove this when packaging with phonegap as we will use the facebookconnectplugin instead.
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
инструменты для разработчиков код сети статус 302
инструменты для разработчиков сети также код состояния 307
Можете ли вы предоставить некоторую информацию (заголовки ответа), какие ошибки это? Из Google Developers Tools (F12 в Chrome)/Сеть –