gpt4 book ai didi

android - 我如何在不检查的情况下从带有 API 墙的 android 应用程序在 facebook 上发帖?

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

我如何在不检查的情况下从带有 API wall 的 android 应用程序在 facebook 上发帖(显示来自 facebook 的“post to wall”屏幕)

最佳答案

只需调用 publishStory(StringYouNeed,StringYouNeed,StringYouNeed);并在您的 Activity/fragment 中实现:

private void publishStory(String hash, String title, String user) {

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(getActivity(), PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Bundle postParams = new Bundle();
postParams.putString("name", title);
postParams.putString("caption", "bla bla");
postParams.putString("description", "bla bla");
postParams.putString("link", "http://blabla.com/"+hash);

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(TAG,
"JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
debug.print("erreur");
}
}
};

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

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

}
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}

非常适合我,希望对您有所帮助。

关于android - 我如何在不检查的情况下从带有 API 墙的 android 应用程序在 facebook 上发帖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17426741/

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