permission denied while using fb_graph rails3
SA
I have a application written in RubyonRails and I want to make him post periodically on facebook fan page. I used fb_graph gem to do that. I created my facebook app and I get my Access Token to use it but when I use this peace of codeme = FbGraph::User.me(ACCESS_TOKEN)
me.feed!(
:message => 'Updating via FbGraph',
:picture => 'https://graph.facebook.com/matake/picture',
:link => 'http://github.com/nov/fb_graph',
:name => 'FbGraph',
:de开发者_开发百科scription => 'A Ruby wrapper for Facebook Graph API'
)
I get permission denied error message.
How can I get the permission to post on my fan page wall?
Thanks in advance.
Link to the docs:
http://developers.facebook.com/docs/authentication/
There are several flows, but essentially, you provide a link for the client to authenticate at facebook:
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=publish_stream,manage_pages
After authing this redirects to a URL on your site prepared to handle the param code
, which you then turn around and send back to facebook for your access_token, which you provide to fb_graph.
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&redirect_uri=YOUR_URLclient_secret=YOUR_APP_SECRET&code=CODE
There are other permissions as well, so you might want to check the facebook docs to see if there are more you need.
Facebook uses OAuth 2 for auth, and there are several ruby gems you can use to facilitate this process slightly, including the oauth2 gem.
The app ID you specified must be wrong. please cross check that. A sample appID looks like this
APP_ID="162221007183726"
Also check whether you have used any call back url. The url should point to a server. Your cannot use your localhost/ local IP there.
A similar nice rails plugin for Facebook app using Rails3 is Koala gem
https://github.com/arsduo/koala/wiki/Koala-on-Rails
http://blog.twoalex.com/2010/05/03/introducing-koala-a-new-gem-for-facebooks-new-graph-api/
精彩评论