如何使用Facebook sdk 3.1在Android应用程序的页面时间轴/墙上发布链接。请帮助我。谢谢。请不要对这个问题进行投票。我试图使用pageid / feed发布。但它显示在“最近的帖子由他人在页面名称”标签下,它由页面所有者发布。我需要显示它在页面的墙上。用于在页面上发布的代码如下
Bundle postParams = new Bundle();
postParams.putString("message","message");
postParams.putString("name","name");
postParams.putString("link",link);
postParams.putString("picture",picture);
postParams.putString("display", "page");
Request.Callback callback = new Request.Callback() {
public void onCompleted(Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
Log.e("FACEBOOK ERROR", ""+ error.getErrorMessage());
} else {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse
.getString("id");
} catch (JSONException e) {
}
}
}
};
Request request = new Request(session,pageid+"/feed",postParams, HttpMethod.POST,callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
答案 0 :(得分:3)
要发布到Page wall,会话值应为null,并将页面的access_token添加为post参数。
Bundle postParams = new Bundle();
postParams.putString("message","message");
postParams.putString("name","name");
postParams.putString("link",link);
postParams.putString("picture",picture);
postParams.putString("access_token", pageaccessToken);
Request.Callback callback = new Request.Callback() {
public void onCompleted(Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
Log.e("FACEBOOK ERROR", ""+ error.getErrorMessage());
} else {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse
.getString("id");
} catch (JSONException e) {
}
}
}
};
Request request = new Request(null,pageid+"/feed",postParams, HttpMethod.POST,callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
答案 1 :(得分:-1)
本指南向您展示如何开始使用Facebook SDK for Android进行开发。
https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/
完整样本
HelloFacebookSample
:一个展示个人资料访问权限,状态更新和照片上传的全方位示例
Scrumptious
:演示如何使用登录,请求,摘录,图片上传和Open Graph发布