Reputation: 11
I have a website where businesses create content through a PHP backend system. Each time they create a new piece of content, I want it to publish to their Facebook pages timeline (not the users timeline).
I have created the authenticate code:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'XXXXXXXXXX',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div class="fb-login-button" scope="manage_pages">
Login with Facebook
</div>
With manage_pages as a scope. I need to know how they can select which page they want the post to go to (if they have more than 1 page), and also how to automatically post to that pages wall when they submit the content (which is done via a PHP form).
Thanks
Upvotes: 0
Views: 382
Reputation: 23713
They have given you the manage_pages permission right? Awesome. Here is what you need to do:
For the other question "how to automatically post to that pages wall when they submit the content (which is done via a PHP form)." I would do some JavaScript logic that will trigger once the form is submitted and call the Facebook API with whatever content you want to POST.
Upvotes: 1
Reputation: 9646
Once users have authorised your app, you should be able to get access to their "accounts" connection. Using this you should be able to retrieve a list of their pages (which you could then use to populate a dropdown) and an access_token for the correct page. You can find more information here https://developers.facebook.com/docs/reference/api/page/ and specifically here https://developers.facebook.com/docs/reference/api/page/#feed
Note that the feed bit refers you to the main article for posts as well, but just remember you need to use the correct access_token and the page_id from above
thanks
Upvotes: 0