Android Facebook-sdf Exception: Failed to generate preview for user

自闭症网瘾萝莉.ら 提交于 2019-12-02 08:18:42

Have been dealing with this error for hours. Heres how I fixed it. The Actions and Objects you specified in your code are the ones that cause the problem.

The samples provided on the Facebook developers guide aren't good enough I feel. Heres a sample code you can use that will work perfectly. Basically make sure your ObjectType -> eg: video.other is set correctly and your Action type e.g: video.watches is set right.

    void sometestCode(){
        OpenGraphObject video = OpenGraphObject.Factory.createForPost("video.other");
        video.setTitle("Awesome Video");
        video.setDescription("This video will show you how to make the Opengraph work");

        OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
        action.setProperty("video", video);
        action.setType("video.watches");            

        FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "video")
                .build();
        uiHelper.trackPendingDialogCall(shareDialog.present());

    }

We had the exact same error some times ago. Check you are using the correct action type in OpenGraphActionDialogBuilder. We fixed the same error just using the correct action type parameter. In your case you should check if "yourcity:visit" is the name of the action. Go to developer consolle https://developers.facebook.com/x/apps/your-app-id/open-graph/action-types/ and click on Get Code for the action you want to implement. Then read the url that should looks like something like this:

https://graph.facebook.com/me/app_namespace:app_action?...

then use the correct app_action in your code. It should fix!

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