Post_Id ShareDialog在Android中始终返回null

时间:2017-10-13 08:18:31

标签: android facebook share

事件展示对话框:

    ShareDialog shareDialog = new ShareDialog(this);
    shareDialog.registerCallback(viewModel.callbackManager, viewModel.facebookCallbackShare, REQUEST_SHARE);
    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent shareLinkContent = new ShareLinkContent.Builder()
                .setContentDescription(description)
                .setContentTitle("title")
                .setQuote(description)
                .setContentUrl(Uri.parse(link))
                .build();
        shareDialog.show(shareLinkContent, ShareDialog.Mode.FEED);
    }
}

和Facebook回调; 我正在使用FacebookCallback与Sharer.Result来监听数据回调:

    public FacebookCallback<Sharer.Result> facebookCallbackShare = new FacebookCallback<Sharer.Result>() {
    @Override
    public void onSuccess(Sharer.Result result) {
        JSONObject data = new JSONObject();
        try {
            data.put("post_id", (result.getPostId() != null) ? result.getPostId() : "postID_dang_null");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onCancel() {

    }

    @Override
    public void onError(FacebookException error) {

    }
};

代码不显示任何错误,但这也不会返回postID。我需要将postid更新为api服务器。

0 个答案:

没有答案