无法使用java在我的Facebook墙上发布
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法使用java在我的Facebook墙上发布相关的知识,希望对你有一定的参考价值。
我想尝试使用Java在我的Facebook墙上发布消息。我已经标记了所有权限。但我得到了异常“FacebookOAuthException”。请帮助解决这个问题。提前致谢!
package com.java.sample.workouts;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.Parameter;
import com.restfb.Version;
import com.restfb.types.FacebookType;
import com.restfb.types.User;
import com.sun.media.jfxmedia.logging.Logger;
public class PostInFBWall {
public static void updateStatus(String message) {
FacebookClient facebookClient= new DefaultFacebookClient("access token", Version.LATEST);
facebookClient.publish("me/feed", FacebookType.class,
com.restfb.Parameter.with("message", message));
}
public static void main(String[] args) {
PostInFBWall.updateStatus("FB testing");
}
}
facebook权限的截图是:
eclipse中的例外是:
Exception in thread "main" com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: (#200) If posting to a group, requires app being installed in the group, and
either publish_to_groups permission with user token, or both manage_pages
and publish_pages permission with page token; If posting to a page,
requires both manage_pages and publish_pages as an admin with
sufficient administrative permission (code 200, subcode null)
at com.restfb.DefaultFacebookClient$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookClient.java:1199)
at com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:1116)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1057)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:979)
at com.restfb.DefaultFacebookClient.publish(DefaultFacebookClient.java:453)
at com.restfb.DefaultFacebookClient.publish(DefaultFacebookClient.java:478)
at com.java.sample.workouts.PostInFBWall.updateStatus(PostInFBWall.java:35)
at com.java.sample.workouts.PostInFBWall.main(PostInFBWall.java:52)
答案
不再可能将消息或照片发布到用户墙,所需的权限将是publish_actions
,但不推荐使用。
以上是关于无法使用java在我的Facebook墙上发布的主要内容,如果未能解决你的问题,请参考以下文章
如何在我的 Facebook 墙上同时发布图像数据和网站 URL