Android Facebook SDK - action.setPlace Error in Custom Stories in Andorid(Feed Dialog Method)

依然范特西╮ 提交于 2019-12-14 03:05:15

问题


I am trying to post a FB Custom story in Android using Open Graph(Share Dialog Method). The code was working very well and posted successfully, until I had added action.setPlace(). Now the Share dialog is appearing correctly. But when I click the 'POST' button, a wierd error message comes as follows

"We are Sorry, this post is no longer available. It may have been removed"

And in onActivityResult(), I get the following exception "com.facebook.FacebookException: Error publishing message"

Here is my code

OpenGraphObject place = OpenGraphObject.Factory
            .createForPost("shellstationstunisia:shell_gas_station");
    place.setProperty("title", "Shell Stations Tunisia");
    place.setProperty(
            "image",
            "http://img1.wikia.nocookie.net/__cb20070306105202/uncyclopedia/images/4/4e/Shell_Logo.png");
    place.setProperty(
            "url",
            "http://www.shell.com/global/aboutshell/contact-us/contact/contact-tunisia.html");
    place.setProperty("description", "Best Gas Station in Tunisia");

    OpenGraphAction action = GraphObject.Factory
            .create(OpenGraphAction.class);
    action.setProperty("shell_gas_station", place);

    //Set a Place - THIS CAUSED THE PROBLEM - Place ID is correct
    GraphPlace my_current_location = GraphObject.Factory
            .create(GraphPlace.class);
    my_current_location.setId("432170683497784");
    action.setPlace(my_current_location);


    @SuppressWarnings("deprecation")
    FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(
            this, action, "shellstationstunisia:travel",
            "shell_gas_station").build();

    uiHelper.trackPendingDialogCall(shareDialog.present());

回答1:


I solved the problem by myself. It was an Authentication issue. I had to enable 'Place' Capabilites from FB Developer Panel. Just follow the steps given below,

  1. In developers.facebook.com, open your app dashboard.
  2. In the Left pane, open 'Open Graph.
  3. Select 'Action Types' tab
  4. Select the Action type for which your getting the above mentioned error.
  5. Scroll down to the section and you will find 'Capabilities' Section
  6. Turn ON 'Place' or any other capability which you would like to use
  7. Click Save Changes.

Now your app would work fine :)




回答2:


I solve this problem by this way:

  1. Open your "Settings" - "Display Name"
  2. Change "Display Name" into your app name (must be the same)

Hope this can help you!



来源:https://stackoverflow.com/questions/27176382/android-facebook-sdk-action-setplace-error-in-custom-stories-in-andoridfeed-d

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