为什么它显示“应用程序请求1”,但在Facebook上的应用程序页面中没有列出任何请求

时间:2011-10-03 03:24:41

标签: facebook facebook-graph-api

enter image description here

就像我附上的图片一样,它显示了1个应用请求,但没有列出任何应用。

使用javascript sdk从图表api发送的apprequests

1 个答案:

答案 0 :(得分:0)

您随应用程序设置的任何应用程序需求都需要被您的应用程序删除。博客中的示例显示了如何连接request_id和user_id以删除未完成的请求。

请参阅http://developers.facebook.com/blog/post/569/


<?php
   require_once('php-sdk/facebook.php');
   $config = array(
     'appId' => 'YOUR_APP_ID',
     'secret' => 'YOUR_APP_SECRET',
   );
   $facebook = new Facebook($config);
?>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:fb="https://www.facebook.com/2008/fbml">
  <head>
     <title>Deleting Requests Example</title>
  </head>
 <body>

<?php
   $user_id = $facebook->getUser();
   if ($user_id) {

      //Get the Request Ids
      $request_ids = explode(',', $_REQUEST['request_ids']); 

      //Construct full Request_Id
      function build_full_request_id($request_id, $user_id) {
          return $request_id . '_' . $user_id;
         }

       //For each Request construct full Request_id and Delete
       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_reqeust_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";
             }   
          }
    }
    //User TOS if user has not authenticated your App
    else if (!isset($_REQUEST['error'])){        
         $params = array(
          'redirect_uri' => 'http://localhost/~namitag/requests.php'
         );
        $loginUrl = $facebook->getLoginUrl($params);
        echo 
          '<script>window.top.location.href="'.$loginUrl.'";</script>'; 
       }
       else {
         echo ("user denied permission"); }

 ?>
</body>
</html>