Facebook FB.ui apprequest,获取所选用户ID
如何检索在应用程序请求对话框生成的多好友选择器中选中的用户ID?我试过:Facebook FB.ui apprequest,获取所选用户ID,facebook,Facebook,如何检索在应用程序请求对话框生成的多好友选择器中选中的用户ID?我试过: FB.ui({ method: 'apprequests', message: 'Here is a new Requests dialog...' }, function (response) { if (response && response.request_ids) { console.log(response.request_ids)
FB.ui({ method: 'apprequests',
message: 'Here is a new Requests dialog...'
}, function (response) {
if (response && response.request_ids) {
console.log(response.request_ids);
}
});
但是我在控制台中没有得到任何结果。谢谢我试过同样的代码。。。。。 首先,“response.request\u id”提供的是请求ID,而不是用户ID api(“/me/apprequests/?request\u id=”提供与request\u id关联的数据。。 但在我的例子中,问题是我得到了一个我甚至没有选择的朋友的随机用户id
FB.ui({
method: 'apprequests',
message: 'You should learn more about this awesome game.', data: 'tracking information for the user'
},function(response) {
if (response && response.request_ids) {
//alert(typeof(response.request_ids));
//alert(response.request_ids);
alert (response.request_ids);
len=response.request_ids.length;
alert(len);
if (len>2) {
alert("Select no more than one friend");
}
else {
user_req_id = response.request_ids[0];
alert (user_req_id);
FB.api('/me/apprequests/?request_ids='+toString(user_req_id),
function(response) {
alert(response);
alert(response['data'][0]['from']['id']);
});
}
}
else {
alert('Post was not published.');
}
});
这是我的密码
FB.ui({
method: 'apprequests',
message: 'Here is a new Requests dialog...'
}, function(res){
if (!res || !res.request_ids) { /* user canceled */ return; }
var req_ids = res.request_ids;
var _batch = [];
for(var i=0; i<req_ids.length; i++ ){
_batch.push({"method":"get","relative_url":req_ids[i]});
}
if(_batch.length>0){
FB.api('/','POST',{batch:_batch},function(res){
//res contains uids.
});
}
});
FB.ui({
方法:“apprequests”,
消息:“这是一个新的请求对话框…”
},功能(res){
如果(!res | |!res.request_id){/*用户已取消*/return;}
var req_ID=资源请求_ID;
var _batch=[];
对于(var i=0;i0){
api('/',POST',{batch:_batch},函数(res){
//res包含uid。
});
}
});
这是一篇关于如何在PHP中获取请求对象以及如何从请求对象中获取信息的文章。在我目前正在开发的应用程序中
response.request_ids
不再存在。它现在似乎正在使用
response.to
它为我提供了用户ID,而不是请求ID。请求ID找不到,但我没有问题,因为我需要用户ID:)
下面是我的响应对象在inspector中的外观
Object
request: 12345678909876
to: Array[2]
__proto__: Object
更新:我刚刚在Facebook API文档中找到了这个。它说明了我上面所说的。
事实证明有一个Requests 2.0 API
在标题
下更新了请求ID格式
下面是新的响应。感谢pferdeflesch
FB.ui({
method: 'apprequests',
message: "Test",
data: "whatever"
}, function (response) {
if (response && response.to) {
for (var j = 0; j < response.to.length; j++) {
alert(response.to[j]);
}
}
});
FB.ui({
方法:“apprequests”,
消息:“测试”,
数据:“随便”
},功能(回应){
if(response&&response.to){
对于(var j=0;j
请求ID不再存在,只想发布最新代码
FB.ui({
method: 'apprequests',
message: "my app request message",
picture: 'url to my image',
max_recipients: 'number of recipients in integer (max 50, 30 for IE6/7)'
}, function(response) {
if(response && response.hasOwnProperty('to')) {
for(i = 0; i < response.to.length; i++) {
console.log("" + i + " ID: " + response.to[i]);
}
}
});
FB.ui({
方法:“apprequests”,
消息:“我的应用程序请求消息”,
图片:“我的图片的url”,
max_recipients:'整数形式的收件人数(IE6/7最大为50,30)'
},功能(回应){
if(response&&response.hasOwnProperty('to')){
对于(i=0;i
感谢FB.ui({method:'apprequests',message:'Test',data:'which',excludeids:excludeids},函数(response){if(response&&response.to){for(var j=0;j