我/饲料Facebook Android sdk 3.0

时间:2013-07-09 13:21:01

标签: android http-post facebook-sdk-3.0

我希望能够从我的Android应用程序分享帖子,但我无法实现它。我已将facebook sdk 3.0添加到我的应用程序中。我可以获得userName,userFirstName,userLastName等。但我无法发送提要。 以下是我使用的代码:

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) {
                        Log.e("Sonuc", "Geldi");
    }
};

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

这个片段来自     https://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/

当我执行此代码时,它会在成功完成后记录。我的意思是Request.Callback的onComplete方法正常工作.. 没有其他任何记录为错误。我不明白为什么它不起作用?它与发布权限有关吗?

此代码段有什么问题?

1 个答案:

答案 0 :(得分:0)

也许你忘了获得“publish_actions”的许可?

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

if (!isSubsetOf(PERMISSIONS, permissions)) {
        pendingPublishReauthorization = true;
        Session.NewPermissionsRequest newPermissionsRequest = new Session
                .NewPermissionsRequest(this, PERMISSIONS);
    session.requestNewPublishPermissions(newPermissionsRequest);
        return;
    }