Mj1992
Mj1992

Reputation: 3504

the target user has not authorized this action facebook graph api

I am trying to post on user wall on behalf of the application.

Here's what I am doing.

First I get the user access_token from facebook connect and then I reciever an extended access token by using the following call

https://graph.facebook.com/oauth/access_token?             
  client_id=APP_ID&
  client_secret=APP_SECRET&
  grant_type=fb_exchange_token&
  fb_exchange_token=EXISTING_ACCESS_TOKEN 

Now when I try to post on friends wall with the following code.

        var params = {};
        params['message'] = 'Check out this new gag I\'ve posted about you surely it will piss you off :p';
        params['name'] = 'Gagsterz';
        params['description'] = 'If you also want to have fun on gagster join in now.';
        params['link'] = 'http://localhost/php/backup/View/Profile.php';
        params['picture'] = thumbpath;
        params['caption'] = 'Caption';


        FB.api('/'+victimid+'/feed?access_token="ACCESS_TOKEN", 'post', params, function(response) {
          if (!response || response.error) {
             var json = $.parseJSON(response.error);
             alert(json.code);
        alert(JSON.stringify(response.error));
          } else {
            alert('Published to stream - you might want to delete it now!');
          }
        });

It gives the following error.

 the target user has not authorized this action facebook graph api
 with code 200.

I take the permission publish_stream and I've tested it by reverting the permission and then logging in to give permissions to it again and the login windows asks for post on behalf permission.But I am taking the permission while I am retrieving the access token for the first time. Do I have to take the permission again for extended access token ? if yes then how to do so ?

Upvotes: 1

Views: 2937

Answers (1)

Androider
Androider

Reputation: 2804

Check your permissions, Do you have permission to Post on wall. By default you will have only read permission.

Check this http://developers.facebook.com/docs/reference/rest/stream.publish/

Upvotes: 1

Related Questions