Publishing a post with privacy “Public” using Facebook SDK

丶灬走出姿态 提交于 2019-12-12 02:48:40

问题



I am using this code to post an image to the user wall

Bundle params = new Bundle();
    params.putString("method", "photos.upload");
    params.putString(
            "caption",
            "Download  link");
    JSONObject privacy = new JSONObject();
    try {
        privacy.put("value", "EVERYONE");
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    params.putString("privacy", privacy.toString());
    byte[] imgData = takeScreenshot();
    params.putByteArray("picture", imgData);
    mAsyncRunner.request(albumId, params, "POST",
            new SampleUploadListener(), null);

My problem is the post privacy is published not as "public" although I set it on my code to "everyone" privacy.put("value", "EVERYONE");
Is there any suggest to post it as "public"
Thanks


回答1:


I solved it flow these steps

Go to your list of apps (https://developers.facebook.com/apps?view=all_apps) Click on your app Click on 'App Details' Scroll down to 'App Center Listed Platforms' and click on the button on the right that says 'Configure App Center Permissions' Change the 'Default Activity Privacy' to public




回答2:


For anyone else looking for an answer I think the easiest way is to just set the default visibility/audience when requesting the permission with:

LoginManager.getInstance.setDefaultAudience(DefaultAudience.EVERYONE);

or

fb_login_button.setDefaultAudience(DefaultAudience.EVERYONE);

For the second one this is how the XML in your layout looks:

        <com.facebook.widget.LoginButton
        android:id="@+id/fb_login_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

See https://developers.facebook.com/docs/reference/android/current/class/DefaultAudience/



来源:https://stackoverflow.com/questions/23726597/publishing-a-post-with-privacy-public-using-facebook-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!