开发者

How to delete all Facebook Graph API apprequests?

$request_url ="https://graph.facebook.com/".$uid."/apprequests?".$access_token;
$requests = file_get_contents($request_url);

This gets all the requests for a user. But how do I del开发者_StackOverflow中文版ete all of them at once? Facebook only has an example for deleting them one by one.

Thanks!


You can't delete multiple items in a single operation (like you can with, say, SQL). You will need to iterate to some degree to specify the unique URL for each request. What you can do is batch up your operations into a single request to Graph API.

More info here at FB.


I know this question is old, but I found it searching on Google so I thought anyone could need an answer now.

The best method for me, is to send all the request ids to Facebook on a single api call.

Your request ids must be on the format requestid_userid, like 12345_67890, supposing you have all the IDs inside an array ($array_of_request_ids), the code (PHP) would be like this:

$ids = implode(',', $array_of_request_ids);
$facebook->api("/?ids={$ids}", 'DELETE');

That should delete all the requests.


  if($requests) {
    foreach($requests as $key => $data) {

        $request_url = "https://graph.facebook.com/" .
                       $data['id'] . "?" . $access_token;

        $requests = file_get_contents($request_url);

        //Delete a request.  
        $delete_url = $request_url . "&method=delete";
        $result = file_get_contents($delete_url);

    }
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜