How to post to Facebook fan page wall as admin
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, St开发者_开发问答ring 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:
- Obtain the
manage_pagespermission from the user - Access the
/me/accountsconnection for that user - Get the access token for each page from the result of that
/me/accountscall - Post to
/{page id}/feedusing the Page Access Token
加载中,请稍侯......
精彩评论