Reputation: 12653
Ok, so fb_graph looks pretty simple to use but Im kinda confused as how to use it.
All I want to do, and when I post a blog entry from my rails app, have the app automatically post to my facebook page.
I have my facebook app_id and app_secret already but Im confused as to what to do with this code:
me = FbGraph::User.me(ACCESS_TOKEN)
me.feed!(
:message => 'Updating via FbGraph',
:picture => 'https://graph.facebook.com/matake/picture',
:link => 'https://github.com/nov/fb_graph',
:name => 'FbGraph',
:description => 'A Ruby wrapper for Facebook Graph API'
)
How do I get that ACCESS_TOKEN? And how do I make sure my posts are going to my fan page and not my personal facebook wall?
Lastly, where does the above code go since I want to post when a blog entry is posted should that code go in the controller under "new" or should it be a method called in the model whenever a blog post is made?
Upvotes: 1
Views: 2261
Reputation: 1956
For the second half of your question: It's likely you want the code to send to Facebook in your model. You can add an after_create callback - this'll fire when the model is first created and saved.
Two things to watch for though - Facebook is an external service, and might be down, slow or send errors back to your app. So, make sure to catch exceptions that might be thrown, or, ideally, use a background job to process the posting.
Upvotes: 1
Reputation: 2425
You should take a look here : Where do I get an access token from to post to my facebook page using FBGraph gem in Rails 3?
It seems that you can generate tokens here :
This links may help too : Error with facebook access token
Upvotes: 2