我正在使用新的FB.ui为我的应用程序在Facebook上创建请求。如何从响应对象FB.ui获取受邀用户ID
用户与他们的朋友一起显示一个面板,他们选择他们想要发送请求的面板。
在回调函数中,我可以访问request_id,现在我想获取被邀请用户的详细信息。
如果我粘贴到浏览器下面的代码,我可以得到它的信息,我希望邀请的用户的USER_ID:
https://graph.facebook.com/138744992885393?access_token=193078857407882|d0048a9beb58a9a247c6b987.0-751640040|zNmBLfZxBBKikoj8RlZiHfKpugM
我希望能够做的是做同样的事情,但从我的代码,然后访问返回的信息。
这里是我的代码:
function sendRequests() {
FB.ui({
method: 'apprequests',
message: ' should learn more about this awesome site.',
data: 'extra data'
}, function(response) {
if (response != null && response.request_ids && response.request_ids.length > 0) {
for (var i = 0; i < response.request_ids.length; i++) {
alert("Invited: " + response.request_ids[i]);
// somehow send a request to Facebook api to get the invited user id from the request_id and save to the database
//can save these id's in the database to be used to track the user to the correct page in application.
}
top.location.href="http://localhost:3000/";
} else {
alert('No invitations sent');
}
});
}
我怎样才能做到这一点?
我使用Rails的Ruby 3.0.7 1.9.2
您可能还希望通过请求/ me/apprequests /?request_ids = {id1},{id2},{id3},{id4}来一次检查所有请求。这可能会更快。 – pixelastic
谢谢Pixelastic我会尝试 – chell