Reputation: 704
How to post a feed in facebook page? I have done in my wall post but i don't know how to do wall post in page using javascript api. Actually, I want like
And I found the code from facebook api. Please help.
Upvotes: 1
Views: 10527
Reputation: 359
Try out this :
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p>
<a href="javascript:;" onclick='postToFeed(); return false;'>Post to Group</a>
</p>
<p id='msg'></p>
<script>
FB.init({appId: "Yourappid", status: true, cookie: true});
function postToFeed() {
// calling the API ...
FB.api('/Pageid/feed', 'post',
{
// for the newer versions of the Facebook API you need to add the access token
access_token: 'page access token'
message : "It's awesome ...",
link : 'Link',
picture : 'Imageurl',
name : 'Featured of the Day',
to: 'Pageid',
from: 'Pageid',
description : 'Your description'
},
function(response) {
if (!response || response.error) {
alert(JSON.stringify(response.error));
} else {
alert('Post ID: ' + response.id);
}
});
}
</script>
</body>
Put into your HTML body tag.
Upvotes: 5
Reputation: 73984
https://developers.facebook.com/docs/reference/api/page/
Search for the feed headline, with this text:
You can create a link, post or status message by issuing an HTTP POST request to the PAGE_ID/feed connection
To impersonate the Page when posting to the wall (i.e. post as the Page, and not the current user), you must use a Page access_token with the manage_pages and publish_stream permissions, as described under Page Access Tokens above.
Upvotes: 1