Retrieve User ID of Facebook App Invitor

五迷三道 提交于 2019-12-25 02:24:22

问题


In the context of a given Facebook app, suppose User A invited user B to start using it. Once User B accepts to use the app, is there any way to retrieve the ID of User A programmatically (via either PHP/JS SDK) ? This doesn't seem quite documented.

For what it's worth, A/B users are friends, if it's any use.


回答1:


when user comes following the app request, you can get request id's using

$_GET['request_ids']

then retrieve all the request ids with which you can call graph api to get the corresponding request details like below:

if(isset($_GET['request_ids']))
     {
          $request_ids = $_GET['request_ids'];
      }
$request_ids = explode(",", $request_ids);
foreach($request_ids as $request_id)
       {
            $request_object = $facebook->api($request_id);
             //this $request_object have sender facebook id in the field uid_from
        }



回答2:


If you look here:

http://developers.facebook.com/docs/reference/dialogs/requests/

You can see the object layout. Of note is the data property:

Optional, additional data you may pass for tracking. This will be stored as part of the request objects created. The maximum length is 255 characters.

In this object you can add your referring UserId and then when the request is claimed, you can then process it on your end.

Hope this helps.



来源:https://stackoverflow.com/questions/12839527/retrieve-user-id-of-facebook-app-invitor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!