应用程序生成的请求使用PHP不工作

function generateAppRequest() {

 try{

   $app_id = '';
   $app_secret = '';

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

   $app_access_token = file_get_contents($token_url);

   $user_id ='';

   $apprequest_url ="https://graph.facebook.com/" .
   $user_id .
   "/apprequests?message=''" . 
   "&data=''&"  .   
    $app_access_token . "&method=post";

   $result = file_get_contents($apprequest_url);
   echo("App Request sent?", $result);

}

catch(Exception $e){
   echo 'Message: ' .$e->getMessage();
}
}

The above code for app generated request does not work. The app does not display anything. Event the exception is not displayed. I am running the app on heroku platform

Here some thoughts you should look at :

  • Are you sure the Heroku platform allows you to go hit facebook webservers ?
  • Maybe fopen and file_get_contents are restricted to regular files on Heroku platform, try the Curl library to access distant URLs.

Good luck with your project