当用户从Friendslist请求对话框窗口中选择朋友时,我正在使用FB.UI()
JavaScript SDK来获取所选的朋友ID。选定的朋友ID将传递给处理程序文件。
上面的情况在Firefox中工作正常,也就是说,我能够得到朋友ID,但是在Internet Explorer 8中也是如此。
在IE8中,当我单击按钮打开朋友请求对话框时,我收到以下错误。
API错误代码:191 API错误说明:指定的URL不归应用程序所有错误消息:redirect_uri不归应用程序所有。
我也给了redirect_uri
,但我没有得到朋友的身份。
代码如下:
function sendRequestToManyRecipients() {
alert("sendRequestToManyRecipients");
FB.ui({method: 'apprequests',
appId : '',
display: 'popup',
message: 'My Group'
}, requestCallback);
}
function requestCallback(response) {
getMultipleRequests(response.request_ids);
}
var friend=new Array();
var sfriend="";
function getMultipleRequests(request_ids)
{
if (response && request_ids)
{
var ids = request_ids;
var _batch = [];
for (var i = 0; i < ids.length; i++)
{
_batch.push({ "method": "get", "relative_url":ids[i] });
}
if (_batch.length > 0)
{
FB.api('/', 'POST', { batch: _batch }, function (res)
{
for (var j = 0; j < res.length; j++)
{
body = res[j].body;
var myObject = eval('(' + body + ')');
friendID = myObject.to.id;
friend[j]=friendID.toString();
}
});
}
}
showfriends();
}
function showfriends()
{
for (var i = 0; i < friend.length; i++)
{
sfriend=sfriend+","+friend[i].toString();
}
if(sfriend != null)
{
window.open("Friends.ashx?id="+sfriend,'WinName','width=900,height=500,left=200,top=200'); }
}
我正在寻找解决方案,但我无法找到正确的解决方案。有人有解决方案吗?
您想获取用户在apprequest对话框中发送的好友ID吗?
考虑使用请求2.0高效,这可以帮助您在发送请求后无需调用另一个api即可获取ID
我之前回答过类似的问题,请看看:how to get user id on facebook request dialog
更新时间:2011-11-29
对于你的参考,我之前使用这个代码用于fb app上的项目,它适用于IE8,Firefox 7,chrome 15
FB.ui({
method : "apprequests",
title : "title",
message : "messafe!!",
display : "iframe"
},
inviteCallback
);
function inviteCallback(response) {
// Requests 2.0 Efficient
// {
// request: ‘request_id’
// to:[array of user_ids]
// }
if (response.request) {
var receiverIDs = response.to;
document.inviteForm.receivers.value = receiverIDs.join(",");
document.inviteForm.submit();
}
}