Deleting requests sent through your app via Facebook graph API

Facebook has silently rolled out a new feature that can be found on their Apps on Facebook section in their documentation.  This feature allows you to delete requests or invites sent through your application via the graph API.  At first glance this seems like a great way to clean out user’s requests, and always keep requests from your application fresh and non-spammy.  The problem is it seems like by deleting requests in this manner, you are actually hurting your accepts to ignore/block ratio.  While testing, we started at the following bucket totals for one of our applications:
Integration Point Limit Bucket/Total
Requests per user per day 16 7/14
Emails per user per day 10 8/8
After 4 days, we found that our bucket totals have dropped to:
Integration Point Limit Bucket/Total
Requests per user per day 8 5/14
Emails per user per day 10 8/8
So while this feature sounds great on paper, Facebook will have to sort out how they handle delete requests before I will be adopting it in our applications.  For posterity, here is the code used (PHP) to delete or list the requests:

<?php

        $app_id = YOUR_APP_ID;

        $app_secret = YOUR_APP_SECRET;

        $token_url = "https://graph.facebook.com/oauth/access_token?" .
             "client_id=" . $app_id .
             "&client_secret=" . $app_secret .
             "&grant_type=client_credentials";

        $access_token = file_get_contents($token_url);

        $user_id = THE_CURRENT_USER_ID;

        $request_url ="https://graph.facebook.com/" .
                $user_id .
                "/platformrequests?" .
                $access_token;

        //If we want to pull the requests via ajax and loop through them
        if($_REQUEST['GETREQUEST']) {
                $requests = file_get_contents($request_url);
                echo json_encode($requests);
        }

        //Handle a delete request.    Note: This will delete ALL requests by your app
        if($_REQUEST['DELETEREQUESTS']) {
                $delete_url = $request_url . "&method=delete";
                $result = file_get_contents($delete_url);
                echo json_encode(array('Deleted' => true));
        }
?>
In our case, we pulled all of the user’s outstanding requests via an ajax call, presented them with an option to take an action (such as share a stream story, or comment on a friend’s results), and then deleted the request if an action was taken.  There are a lot of beneficial user flows through an application when this method works properly!
相關文章
相關標籤/搜索