FB 应用程序请求后重定向
我发现了一些执行 fb 请求的示例代码:
但我的目标是在这个 jquery 帖子之后重定向?我对 jquery post 不熟悉...... 此代码只是打开对话框然后关闭。我想刷新页面或重定向到另一个页面。我将请求发送到 fbrequests,它执行一些 php 代码,将请求信息存储到我服务器上的数据库。我尝试将重定向放在那里,但它不起作用。
它是
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");
}
});
}
I found some sample code that does fb requests:
But my goal is to redirect after this jquery post? Im not familiar with jquery post....
This code just brings the dialogue box then closes. I want to refresh the page or redirect to another. I am sending the requests to fbrequests which executes some php code that stores request info to my db on my server. I tried putting the redirect there but it doesnt work.
Its
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");
}
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除包装
jQuery(function(){});
并仅使用:还可以使用下面的内容来加入
request_ids
而不是您的代码:取自我的教程:如何:处理应用程序请求使用 Facebook 图谱API
Remove the wrapping
jQuery(function(){});
and just use:Also use the below to join the
request_ids
instead of your code:Taken from my tutorial: How To: Handle Application Requests Using The Facebook Graph API