如何使用 Requests 2.0 获取用户在 Facebook 应用中邀请的好友列表

发布于 2024-11-08 11:30:24 字数 432 浏览 0 评论 0原文

我正在使用新的Requests 2.0(http://developers.facebook.com/docs/reference/dialogs/requests/)

所以我设置了一切并且工作正常 - 我只剩下一个问题了。当用户选择邀请 50 位朋友使用我的应用程序时。我需要的是这些被邀请者的用户 ID(这样用户就无法再次邀请他们)。

我现在要做的就是通过这样的调用获取每个用户 ID: $data = $facebook->api('/'.$request_id.'/'); $user_id = $data['to']['id'];

所以我循环遍历所有 50 个 $request_id 并获取用户的 id。

但这当然非常慢,因为我做了 50 个请求(有时它根本不起作用......)。那么有没有更好的方法从新的 Requests 2.0 对话框中获取受邀用户 ID???

im using new Requests 2.0 (http://developers.facebook.com/docs/reference/dialogs/requests/)

So i set up everything and is working ok - i have only one problem left. When a user selects 50 friends to invite to my app. What i need is the user ID's of these people invited (so user cannot invite them again).

What i do now is to get every user id with a call like this:
$data = $facebook->api('/'.$request_id.'/');
$user_id = $data['to']['id'];

So i loop trough all 50 $request_id's and get the user's id's.

BUT this is afcourse very slow, since i do 50 request (sometimes it doesnt work at all...). So is there any better way to get invited users id from new Requests 2.0 dialog???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蘑菇王子 2024-11-15 11:30:24

在这个阶段,似乎没有替代策略可以循环遍历所有 request_ids。
为什么不尝试将从对话框中返回的 request_ids 分成较小的组,并可能在处理组之间放置短暂的暂停...或者利用批处理请求在请求之间再次稍微暂停。这些请求需要时间 - 您必须禁用对话框的触发器,直到完成 request_ids 的处理,然后将这些用户 IDS 添加到 exclude_ids 属性。

如果您限制用户仅向每个用户发送一个请求,您可能会考虑仅在请求得到响应时管理您的请求...
您允许用户向任意数量的用户发送任意数量的请求 - 然后,当该请求得到响应时,您将循环遍历该用户的未完成请求并删除同一用户的请求,类似于您上面提到的:

$data = $facebook->api('/'.$request_id.'/','DELETE');

At this stage it doesnt look like there is an alternative strategy to looping through all the request_ids.
Why not try splitting the request_ids you get back from the dialog into smaller groups and maybe placing a short pause between processing groups... or utilize the batch requests again pause slightly between requests. These requests will take time - you'll have to disable the trigger for the dialog until you finish processing the request_ids and then add those user IDS to the exclude_ids property.

If you are limiting your users to send only one request to each user you might consider also managing your requests only when they are responded to...
You allow users to send as many requests to as many users as they want - then when that request is responded to you loop through THAT users outstanding requests and delete ones from the same user, similar to what you mentioned above :

$data = $facebook->api('/'.$request_id.'/','DELETE');

糖粟与秋泊 2024-11-15 11:30:24

我所做的就是获取用户好友列表,然后使用从请求信息中获取的用户 ID 查找好友姓名。

What I did was get the list of user's friends and then just look up friend names using the user IDs that I got from the request info.

半步萧音过轻尘 2024-11-15 11:30:24

只需在一次调用中检查所有请求的完整详细信息:

https://graph.facebook.com/?access_token=<访问令牌>&ids=<请求 IDS 的 CSV 列表>

Just check the full details of all requests in a single call:

https://graph.facebook.com/?access_token=<ACCESS TOKEN>&ids=<CSV LIST OF THE REQUEST IDS>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文