I know, I know. This is a blog about Open Technologies and Open Web and I am writing about Facebook. Shame on me :)
It’s a little bit tricky and I’ve lost 3 hours to resolve it and that’s the reason to post it here
Here is the solution.:
1. If you are reading this, probably you have Application setup-ed already in Facebook;
2. Add your application to your Page;
3. Run this link in your Browser. Please replace ~URL~ with your connect URL (Facebook Application dialog) and ~APPID~ with your application ID
https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=~APPID~&redirect_uri=~URL~&scope=publish_stream,offline_access,manage_pages
4. This URL will return to you a URL parameter access_token.
5. Save the token somewhere;
6. Load This URL. Replace ~TOKEN~ with the token received from Facebook at point 4.;
https://graph.facebook.com/me/accounts?access_token=~TOKEN~
7. As a result you will get the json with all your pages and all access tokens. Save them somewhere;
{
"name": "Electronic Frontier Bulgaria",
"category": "Websites",
"id": "29469045921",
"access_token": "some secret string."
},
8. Use FB js SDK to update your page. Replace ~PAGE_AUTH~ with access_token from the previous point. (some secret string)
var wallPost = {
access_token: "~PAGE_AUTH~",
message: 'Talkweb.eu is the best :)'
};
FB.api('/me/feed', 'post', wallPost, function(response) {
if (!response || response.error) {
alert('Error occurred');
} else {
alert('Success!');
}
});
9. Check the page to see the result;
10. Bye me a beer or hire me :)
If you have any questions, please let me know!
Leave a Reply