gpt4 book ai didi

android - 使用 Facebook sdk 3.1 发布指向 Facebook 页面墙的链接

转载 作者:行者123 更新时间:2023-11-29 00:29:10 25 4
gpt4 key购买 nike

如何使用 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();

最佳答案

要发布到页面墙,session 值应为 null 并添加页面的 access_token 作为发布参数。

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();

关于android - 使用 Facebook sdk 3.1 发布指向 Facebook 页面墙的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17039629/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com