facebook-graph-apioauthapprequests

OAuthException: (#2) Failed to create any app request


I am using following code to send request from application to user. Everything was fine, but suddenly it stops to work and I get an error: OAuthException: (#2) Failed to create any app request

$config = array();
$config['appId'] = $this->app_id;
$config['secret'] = $this->app_secret;
$facebook = new Facebook($config);
$url = "https://graph.facebook.com/oauth/access_token?client_id={$this->app_id}&client_secret={$this->app_secret}&grant_type=client_credentials";
$token = file_get_contents($url);
$request = $facebook->api('/'.$id.'/apprequests', 'POST', array(
   'message' => $text,
   'access_token' => $token
  )
  );

Looks like token is valid, and I don't know where else can be the problem.


Solution

  • The endpoint does not return the token only, but a string in the form access_token=YOUR_APP_ACCESS_TOKEN.

    So what you are passing as access_token parameter is not really an access token – you’ll have to trim the access_token= first.