当用户从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'); }
}
我正在寻找解决方案,但我无法找到正确的解决方案。 有人有解决方案吗?
答案 0 :(得分:0)
您是否想要获取用户在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();
}
}