0

Hi Im trying to write a facebook application that will post a photo to a users page. Ive pretty much word for word followed this tutorial.

but whenever I try and upload a photo I get this error:

{
   "error": {
      "type": "OAuthException",
      "message": "A user access token is required to request this resource."
   }
}

I beleive the problem is coming from this code as I'm sending the AppID, AppSecret and post_login_url (which are all correctly populated) however $response is completely blank:

   $token_url= "https://graph.facebook.com/oauth/"
         . "access_token?"
         . "client_id=" .  $app_id 
         . "&redirect_uri=" . urlencode( $post_login_url)
         . "&client_secret=" . $app_secret
         . "&code=" . $code;
         $response = file_get_contents($token_url);
         $params = null;
         parse_str($response, $params);
         $access_token = $params['access_token'];

Any help would be appreciated, as always im on a tight deadline

Thanks,

Doug

1
  • $response is completely blank Did you mean you have trouble with file_get_contents() function? Did you try to using cURL or fopen() ?
    – toopay
    Jul 26, 2011 at 15:27

1 Answer 1

0

The Application Access token is used to make API calls on behalf of an app, your underlying issue is likely that the API call you're trying to make has to be made on behalf of a User and needs a user access token produced when a user authorises your app. The code you have above should be fine for getting an App Access token

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.