0
我發現了一些示例代碼,做fb請求:FB應用程序請求後重定向
但我的目標是重定向後,此jquery後?我不熟悉jquery帖子.... 這段代碼只是帶來了對話框,然後關閉。我想刷新頁面或重定向到另一個頁面。我將請求發送到執行一些php代碼的fbrequests,該代碼將請求信息存儲到我的服務器上的數據庫。我試圖把重定向放在那裏,但它不起作用。
其
function sendRequest(to) {
FB.ui({method: 'apprequests',
message: 'data',
data: to,
title: 'Invite your Facebook friends.'},
function (response) {
if (response && response.request_ids) {
//since csv, we convert to string
var requestIds = "";
for(var i = 0; i < response.request_ids.length; i++){
requestIds = requestIds + response.request_ids[i] +",";
}
//modifications
//now requestIds is 123,124,125, so we need to remove the last comma after the last id
requestIds = requestIds.substring(0,requestIds.length-1);
jQuery(function(){
jQuery.post("fbrequests", { request_ids: requestIds }); //jquery post to send csv list of ids to php processing file
// window.location.href='http://mysite.com/my-friends';
});
} else {
//Do something if they don't send it.
//alert("Didnt send it");
}
});
}
Facebook剛剛發佈了請求2.0 - LINK - http://developers.facebook.com/blog/post/464/ - 這個新的更改request_ids不再提供。相反,您可以通過這種方式獲取用戶ID:var Ids = response.to.join(','); – ivias