发送Facebook请求并获得FB API的礼物 [英] send Facebook request and get a gift FB API

查看:110
本文介绍了发送Facebook请求并获得FB API的礼物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设法实现了我的应用在Facebook上的发送请求功能,文档这里

I've managed to implement the "send Request" functionality for my App on facebook following the docs here

现在,如果用户'A'接受用户'B'发送给他的请求,我希望用户'B'获得特定应用的礼物(图像)。
我的问题是,我怎么知道是用户'B'谁邀请用户'A'? (而不是用户'C')

Now, in case user 'A' accepts a request sent to him by user 'B', I want user 'B' to get an app-specific gift (image). My question is, how would I find out it was user 'B' who invited user 'A'? (and not user 'C')

谢谢。

推荐答案

将请求ID与发起请求的用户B一起存储在数据库中。

Store the request id in your database along with the user B who initiated the request.

当用户A点击请求时,他们将被重定向到您的应用,Facebook将发送你的请求ID。在您的数据库中查找请求ID以获取发起的用户。

When user A clicks on the request they will be redirected to your app and Facebook will send you the request id. Look up the request ID in your db to get the user who initiated.

获取请求ID的一些示例包含在Facebook 有关删除请求的文档

Some examples of getting the request id are included in the Facebook documentation about deleting requests.

虽然不是技术性的,还要查看有关请求最佳做法的文档,其中包含赠送部分

Although not technical, you might also want to review the documentation on requests best practices which has a section on gifting.

另一种方法是从图形API获取发件人(注意这几乎总是比上述解决方案慢)。通过将user_id连接到request_id,您有一个特定的请求对象id,您可以向图形API发出如下所示的 GET 请求:

An alternative is to get the sender from the graph api (note this is almost always slower than the above solution). By concatenating the user_id to the request_id you have a specific request object id, and you could issue a GET request to the graph API that looks like this:

https://graph.facebook.com/<REQUEST_OBJECT_ID>?access_token=APP_ACCESS_TOKEN

在回复中,发件人位于属性中:

In the response, the sender is in the from attribute:

{
  "id": "259855964134806_4", 
  "application": {
    "name": "Betcafe",
    "namespace": "betcafe-play", 
    "id": "240039049434634"
  }, 
  "to": {
    "name": "Zuck", 
    "id": "4"
  }, 
  "from": {
    "name": "Todd Chaffee", 
    "id": "532338216"
  }, 
  "message": "Join my team so we can pass balls to each other and help Milan win the weekly cup!", 
  "created_time": "2012-09-10T16:43:45+0000"
}

这篇关于发送Facebook请求并获得FB API的礼物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆