无法为用户生成预览 - Facebook android SDK 4.2

时间:2015-06-04 11:46:16

标签: android facebook

我目前正致力于在Facebook上分享一个地方。

这是我的代码

// Create an object
            ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
                    .putString("og:type", "anewplace")
                    .putString("og:title", "Paris")
                    .putDouble("place:location:latitude", 10.7672788)
                    .putDouble("place:location:longitude", 106.6877127)
                    .build();

            // Create an action
            ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                    .setActionType("come")
                    .putObject("anewplace", object)
                    .build();

            // Create the content
            ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
                    .setPreviewPropertyName("anewplace")
                    .setAction(action)
                    .build();


            ShareButton shareButton = new ShareButton(this);
            shareButton.setShareContent(content);
            shareButton.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {

                @Override
                public void onSuccess(Sharer.Result result) {
                    Log.i(TAG, "SHARING SUCCESS!");
                }

                @Override
                public void onError(FacebookException error) {
                    Log.e(TAG, "SHARING ERROR! - " + error.getMessage());
                }

                @Override
                public void onCancel() {
                    Log.w(TAG, "SHARING CANCEL!");
                }
            });

            shareButton.performClick();

我收到错误:无法为用户生成预览

我按照文档创建了自定义故事

请帮忙:)谢谢

1 个答案:

答案 0 :(得分:0)

我找到了方法:)

对于操作,它应该是这种格式&#34; app_name:action_name&#34; 对于对象,它应该是&#34; app_name:object_name&#34;