我正在创建一个应用程序来管理Facebook上的发布。 我可以发布基本的Facebook消息,且没有错误,并在我的页面相册中上传本地图像。
问题出在后面。上传我的图片并使用其ID捕获我的图片帖子的来源后,该消息成功发布,但出现了身份验证错误。
我正在使用Ajax来执行此操作,并注意到(查看我的代码),我的控制台打印了以下命令:
1.“成功01”
2.“完整”
3.“成功02”
代替
1.“成功01”
2.“成功02”
3.“完整”
有人知道我在做什么错吗?
$.ajax({
url: 'https://graph.facebook.com/me/photos?access_token=' + response.access_token,
type: 'POST',
data: data,
processData: false,
contentType: false,
cache: false,
success:function (data) {
FB.api( // BEGIN: IMAGE HAS BEEN UPLOADED, NOW LET'S GET THE IMAGE URL TO USE
'/'+ data.id,
'GET',
{"fields":"images"},
function(response) {
var getFirstImage = response.images[0].source;
console.log("succes 02");
FB.api( // BEGIN OF FB API TO POST BASIC MESSAGE
'/'+ val + '/feed',
'POST',
{message: message, link: link, source: getFirstImage, access_token: response.access_token},
function(response) {
console.log(response);
$("#" + val).addClass('postsucces');
$(".feedbackresponse").html("<span class='succesFeedback'>Alright! Every post was a succes</span>");
}); // END OF FB API TO POST BASIC MESSAGE
}); // END: IMAGE HAS BEEN UPLOADED, NOW LET'S GET THE IMAGE URL TO USE
$('.feedbackresponse').append('<p>Photo was successfully uploaded, object id is: ' + data.id + '</p>');
console.log("succes 01");
},
error:function (data) {
$('.feedbackresponse').append('<p>A problem occurred during upload</p>');
},
complete: function () {
console.log("complete");
}
});
};