我想使用访问令牌在用户的Facebook墙上发布消息。但我无法做到这一点。任何人都可以为我提供相同的代码吗?我已经拥有了用户的访问令牌。
当我尝试这个时,它总是问我的凭据在发布之前登录到facebook。
答案 0 :(得分:2)
您无法使用访问令牌在用户的Facebook墙上发布消息。
ApplicationSettings sett=new ApplicationSettings(NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, USER_PERMISSIONS);
facebook_=Facebook.getInstance(sett);
user = facebook_.getCurrentUser();
然后,如果要保存用户,请保存。然后
user.publishPost(your post details(link, image title.....));
答案 1 :(得分:0)
您可以user.publishPost()
发布到用户留言板。请检查以下代码段
String[] PERMISSIONS = Facebook.Permissions.PUBLISHING_PERMISSIONS;
ApplicationSettings as = new ApplicationSettings(NEXT_URL, APPLICATION_ID,
APPLICATION_SECRET, PERMISSIONS);
User user;
Facebook fb;
fb = Facebook.getInstance(as);
fb.getCurrentUser(new BasicAsyncCallback() {
public void onComplete(
com.blackberry.facebook.inf.Object[] objects,
final java.lang.Object state) {
user = (User) objects[0];
log("Posting to wall");
user.publishPost(message, link, picture, name, caption,
description, source, new BasicAsyncCallback() {
public void onComplete(String[] values,
java.lang.Object state) {
log("Posted successfully to your facebook wall");
}
}, null);
}