4

私がAで、AがBに招待を送信するとします.Bが私の友達リクエストを受け入れると、私のページでリクエストIDを取得していますが、どうすれば私のPHPページで私のUID(A)を取得できますか?

私を助けてください。このために6時間から苦労しています。

request_Id を取得するために、これらの (以下を参照) コードを使用しています。しかし、これらからSENDERS 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 に答える