我正在使用新的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