0

I'm getting error while posting a feed on my facebook from url:

(#200) The user hasn't authorized the application to perform this action

I'm using

https://graph.facebook.com/me/feed?name=hello&message=hello_from_url&access_token=access_token

as my URL. I'm creating a rails app for which I need scope parameter so that I can post on my timeline from rails app but I'm unable to find out the exact solution.

Learner
  • 1,277
  • 3
  • 15
  • 34
Braham Shakti
  • 1,408
  • 4
  • 22
  • 39

1 Answers1

3

First thing is that adding scope parameter to this posting URL is useless, permissions are set on first use of app depending on the permissions definded in the scope on auth dialog.

Your application needs publish_actions permission to post feed. And if you add this permission to config you have to authenticate to your app again to accept new permissions.

Use Graph API Explorer to check if everything is fine with this. Select your application from dropdown in the top right corner, change method to POST and paste me/feed?name=hello&message=hello_from_url. Then run it and check if you have this exception or not. Click Get Access Token to check permissions you granted your app.

And BTW, you can use fb_graph to post feed, if you're not using it:

me = FbGraph::User.me(access_token)
 me.feed!(
    :message => '',
    :link => '',
    :name => '',
    :description => ''
  )
Konrad Gadzina
  • 3,407
  • 1
  • 18
  • 29
  • My omniauth config file look like this: Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET'], {:scope => "offline_access,read_stream ,manage_pages, publish_stream, publish_actions"} end but still no success. – Braham Shakti Feb 04 '13 at 10:39
  • @BrahamShakti OmniAuth is for authorization only. You need something more to use Facebook Graph API, like `fb_graph mentioned by me above. [Here](http://superp.tumblr.com/post/4109090091/publish-stream-in-facebook-twitter-with-omniauth) is an example. – Konrad Gadzina Feb 04 '13 at 10:56
  • I just wanted to know how do i post feed from url. I am aware of omniauth and what konrad is telling, i already have tried, please click [here](http://stackoverflow.com/questions/14642142/how-do-i-solve-fbgraphunauthorized-oauthexception-200-the-user-hasnt-a) for reference – Braham Shakti Feb 04 '13 at 11:38
  • @BrahamShakti First thing is that adding `scope` parameter to this posting URL is useless, permissions are set on first use of app. Have you authenticated to the app again after adding `publish_actions` to config? Use [Graph API Explorer](https://developers.facebook.com/tools/explorer/) to check if everything is fine with this. Select your application from dropdown in the top right corner, change method to POST and paste `me/feed?name=hello&message=hello_from_url`. Then run it and check if you have this exception or not. Click `Get Access Token` to check permissions you granted your app. – Konrad Gadzina Feb 04 '13 at 14:26
  • Thank you Konrad that really helps me. It solves my problem. I am really thankful to you. – Braham Shakti Feb 05 '13 at 05:11
  • @BrahamShakti Great. I have updated my answer to provide info from my last comment. If this answer helps you please mark it as accepted. – Konrad Gadzina Feb 05 '13 at 10:22
  • Thanks for the answer. I was also facing the same problem. Now I got what i want. – mohitum Feb 06 '13 at 11:53
  • @KonradGadzina, thanks for the answer, I got it working with the help of this :) – sameera207 Apr 11 '14 at 12:59