4

假设我是 A。A 向 B 发送邀请。当 B 接受我的好友请求时,我会在我的页面上获取请求 ID,但是如何在我的 php 页面上获取 Mine(A) 的 UID?

请帮我。我为此奋斗了 6 小时。

我正在使用这些(见下文)代码来获取 request_Id。但是从这些我怎样才能获得发件人 ID?

 <?php
    require_once('phps/fbsdk/src/facebook.php');
    $config = array
    (
      'appId' => '27c3932323897****82',
      'secret' => '******************************',
    );
    $facebook = new Facebook($config);
    //get the request ids from the query parameter
     $request_ids = explode(',', $_REQUEST['request_ids']);

     //build the full_request_id from request_id and user_id
      function build_full_request_id($request_id, $user_id) {
      return $request_id . '_' . $user_id;
     }

     //for each request_id, build the full_request_id and delete request
     foreach ($request_ids as $request_id)
     {
     echo ("reqeust_id=".$request_id."<br>");
     $full_request_id = build_full_request_id($request_id, $user_id);
     echo ("full_request_id=".$full_request_id."<br>");

    try {
     $delete_success = $facebook->api("/$full_request_id",'DELETE');
     if ($delete_success) {
        echo "Successfully deleted " . $full_request_id;}
     else {
       echo "Delete failed".$full_request_id;}
    }
    catch (FacebookApiException $e) {
    echo "error";}
    }
 ?>`
4

1 回答 1

3

使用您获得的请求 ID 调用图形 api (graph.facebook.com/{REQUEST_ID}),您将收到发件人 ID,您将获得如下信息:

{
  "id": "493703870648580", 
  "application": {
    "name": "Send Requests How To", 
    "id": "403223126407920"
  }, 
  "to": {
    "name": "Chris Abe Colm", 
    "id": "100003086810435"
  }, 
  "from": {
    "name": "Christine Abernathy", 
    "id": "1424840234"
  }, 
  "data": "{\"badge_of_awesomeness\":\"1\",\"social_karma\":\"5\"}", 
  "message": "Learn how to make your Android apps social", 
  "created_time": "2012-10-07T17:29:57+0000"
}

有关图形 api 的更多信息:http: //developers.facebook.com/docs/reference/api/

PS:从您的示例中删除您的应用程序机密

于 2013-01-15T09:47:42.970 回答