PHP中的请求对话框处理

PHP中的请求对话框处理,php,facebook-graph-api,request,Php,Facebook Graph Api,Request,到现在为止,我一直在使用下面的代码,不幸的是,它不再工作了。谁能帮帮我吗。我是一个真正的初学者,所以我会很感激整个代码或者我应该修改的内容。如何在php中获取ID请求、ID用户和ID用户到? 多谢各位 <script> FB.init({ appId : '111111111111111', status : true, cookie : true, oauth: true });

到现在为止,我一直在使用下面的代码,不幸的是,它不再工作了。谁能帮帮我吗。我是一个真正的初学者,所以我会很感激整个代码或者我应该修改的内容。如何在php中获取ID请求、ID用户和ID用户到? 多谢各位

 <script>
      FB.init({
        appId  : '111111111111111',
        status : true,
        cookie : true,
        oauth: true
      });    
      function sendRequestViaMultiFriendSelector() {
        FB.ui({method: 'apprequests',
          message: 'My Great Request'
        }, requestCallback);
      }

      function requestCallback(response) {
      $.post("process_ids.php", {uid: <?php echo $uid; ?>, request_ids: String(response.request_ids) } ); 
      return false;
      }
    </script>

///////////////////////process_ids.php :

<?php
    $appid  ='11111111111111';
    $secret ='22222222222222222';

if(isset($_POST['request_ids']) && !empty($_POST['request_ids'])){

$app_token = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id='.$appid.'&client_secret='.$secret.'&grant_type=client_credentials'); //Get application token

$sent   = explode(',', $_POST['request_ids']);  //Convert csv to array
$count = count($sent); //count how many objects in array    
for ($a = 0; $a < $count; $a++) {    
$request = file_get_contents('https://graph.facebook.com/'.$sent[$a].'?'.$app_token);

preg_match("/\"to\":\{\"name\":\"(.*?)\",\"id\":\"(.*?)\"/i", $request, $getInfo);

$sent_to_name = $getInfo[1];
$sent_to_id = $getInfo[2];

preg_match("/\"id\":\"(.*?)\"/i", $request, $getInfo);
$idrequest = $getInfo[1];

 $delete_url = "https://graph.facebook.com/" . $idrequest . "?" . $app_token . "&method=delete";
}
} ?>

FB.init({
appId:'111111111',
状态:正确,
曲奇:是的,
真的吗
});    
函数sendRequestViaMultiFriendSelector(){
ui({method:'apprequests',
信息:“我伟大的请求”
},请求回调);
}
函数requestCallback(响应){
$.post(“process_id.php”,{uid:,request_id:String(response.request_id)});
返回false;
}
///////////////////////process_ids.php:

FB传递给您的答案是JSON编码的。您不必编写regexp,只需获取存储在$request变量中的答案,然后使用json_decode()将其

像这样:

$request = file_get_contents('https://graph.facebook.com/'.$sent[$a].'?'.$app_token);
$answer = json_decode($request);
// that's for debugging only
echo '<pre>';
print_r($answer);
echo '<pre>';
$requests=$this->facebook->api('/me/apprequests/'); //Requests Graph API call.
foreach($requests['data'] as $request) {
   $this->facebook->api($request['id'], 'delete'); // delete the used request
}