Search code examples
facebookapprequests

Failed to create any app request


I want to send a request with the facebook app-graph.. sometimes successfully but sometimes failed with return value:

{
   "error": {
      "message": "(#2) Failed to create any app request",
      "type": "OAuthException",
      "code": 2
   }
}

please help me .. why did it happen?hehe


Solution

  • You need to send the app-to-user request using the application access_token. For example:

    $param = array(
       'message'      => 'Check out the latest update',
       'data'         => 'some_data_string',
       'access_token' => 'app_id|app_secret',
    );
    $tmp = $facebook->api("/[user_id]/apprequests", "POST", $param);
    

    EDIT:

    See the facebook documentation for generating an app access_token. The documentation states:

    There is another method to make calls to the Graph API that doesn't require using a generated app token. You can just pass your app id and app secret as the access_token parameter when you make a call:

    https://graph.facebook.com/endpoint?key=value&access_token=app_id|app_secret