gpt4 book ai didi

android facebook post api 不工作

转载 作者:行者123 更新时间:2023-11-30 03:37:49 25 4
gpt4 key购买 nike

我正在使用 android facebook api 在用户提要上发布。

登录成功,但是函数 publishstory 不起作用。我有下面的代码。

private void publishStory() {

Session session = Session.getActiveSession();

if (session != null){

// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}

Bundle postParams = new Bundle();
postParams.putString("name", "Facebook SDK for Android");
postParams.putString("caption", "Build great social apps and get more installs.");
postParams.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
postParams.putString("link", "https://developers.facebook.com/android");
postParams.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");

Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i("error",
"JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(FacebookActivity.this.getApplicationContext(),
error.getErrorMessage(),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(FacebookActivity.this
.getApplicationContext(),
postId,
Toast.LENGTH_LONG).show();
}
}
};

Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);

RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}

}

问题是它执行到行

session.requestNewPublishPermissions(newPermissionsRequest);
return;
}

然后在返回时退出函数,不显示任何弹出窗口。有什么想法吗?

最佳答案

引用这段代码->

FbShare Code Pattern Gist

关于android facebook post api 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16371068/

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