Try this out
<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',
{
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>
Another Way
Main challenge is getting permanent access token that will let us act on behalf of a page admin, the rest is very similar to making a regular wall post. Getting access token would require asking one of page admins for manage_pages extra permissions and then retrieving their "accounts" information that would contain access_token fields for every page where they have admin permissions.
FB.login(function() {
FB.api('/me/accounts', 'get', {}, function(response) {
console.log(response);
});
}, {perms:'publish_stream,offline_access,manage_pages'});
Pass just retrieved access token among other wall post parameters
//API init code is omitted
var wallPost = {
access_token: "<ACCESS_TOKEN>",
message: 'Hello, World!'
};
FB.api('/me/feed', 'post', wallPost, function(response) {
if (!response || response.error) {
alert('Error occurred');
} else {
alert('Success!');
}
});
Key is to get right access token. you can try firebug in browser and test your access token which you get here https://developers.facebook.com/tools/debug/