I am using RestFb as a java wrapper to make calls to Facebook graph API. I want to post to my fan page as admin. Currently, all posts appear as my personal posts. I have taken the access_code using “manage_pages” as one of the permissions. Here is my code:
public void postOnWall(String wallId, String message, String picture, String link, String linkname, String caption, String description) throws FacebookException {
facebookClient.publish(wallId+"/feed", FacebookType.class,
Parameter.with( "message", message),
Parameter.with( "picture", picture),
Parameter.with( "link", link),
Parameter.with( "name", linkname),
Parameter.with( "caption", caption),
Parameter.with( "description", description));
}
and in my calling method:
try {
FacebookService facebookService = new FacebookService("access_token");
facebookService.postOnWall("page_id", comment, "image", "link", title, "caption", description);
} catch (FacebookException e1) {
e1.printStackTrace();
}
I have replaced all parameters in double quotes with the actual values. What else is required?
To post as the page itself you need to use the Page Access Token,
To retrieve this you need to:
manage_pagespermission from the user/me/accountsconnection for that user/me/accountscall/{page id}/feedusing the Page Access Token