Facebook分享 - 缺少文本

时间:2014-11-10 13:11:11

标签: android facebook facebook-graph-api

原始问题

我做了更多的研究,看到帖子底部的信息。谢谢!

我是一款Android应用,拥有Facebook分享选项。我主要是从Fb的教程中完成应用程序的共享部分。开发。网站,请参阅:https://developers.facebook.com/docs/android/share

这是实际的代码:

Request.newMeRequest(session, new Request.GraphUserCallback() {
    @Override
    public void onCompleted(GraphUser user, Response response) {
        Bundle postParams = new Bundle();
        String name = String.format(getResources().getString(R.string.shareFacebook_title), user.getName(), petName);
        String caption = String.format(getResources().getString(R.string.shareFacebook_caption));
        String description = String.format(getResources().getString(R.string.shareFacebook_description), user.getName(), petName, shelterName);
        postParams.putString("name", name);
        postParams.putString("caption", caption);
        postParams.putString("description", description);
        postParams.putString("link", getResources().getString(R.string.shareFacebook_url));
        postParams.putString("picture", petPicUrl);

        Request request = new Request(session, "me/feed", postParams,
                HttpMethod.POST);

        RequestAsyncTask task = new RequestAsyncTask(request);
        task.execute();
    }
}).executeAsync();

我的问题是,共享链接没有所有文本,我放入bundle。见图:

Facebook share

当我运行调试器并调试到应用程序时,所有postParams运行正常,而Bundle包含所有文本,但共享看起来相同(并且没有全部(文本) Bundle会引发一些意外的ClassNotFoundExceptions,但我认为它在IDE中出错,请参阅此SO question

Debugging in the IDE

所有手机的遗失文字都不一样。对于某些手机,图片也是missis,但我确定,网址是对的。

我知道,这项工作在2-3周前完成,直到今天才触及此代码。

你能帮助我吗,导致问题的原因是什么? 谢谢!

修改

我已经尝试了Facebook Graph API Explorer,发送相同的查询,我也得到了相同的结果(缺少文本等)。

以下是查询:

The same query from the Graph API Explorer

有可能,Graph API错误/坏了吗?它在过去几周有变化吗? status page说,API是健康的。

修改#2

好的,所以如果我想分享任何链接,那么thoose属性就可以了。但是,如果我要分享指向Google Play的链接,则属性会停止工作。

2 个答案:

答案 0 :(得分:2)

可能导致我的问题是Google Play商店在代码中定义了oauth代码,因此FB会解析该代码而不是我的内容。

我发现,最好的解决方案是链接到一个空白网站,我用JavaScript重定向用户。

答案 1 :(得分:0)

而不是使用Facebook拨号

private void publishFeedDialog() {
    Bundle params = new Bundle();
    params.putString("name", "Facebook SDK for Android");
    params.putString("caption", "Build great social apps and get more installs.");
    params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
    params.putString("link", "https://developers.facebook.com/android");
    params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");

    WebDialog feedDialog = (
        new WebDialog.FeedDialogBuilder(getActivity(),
            Session.getActiveSession(),
            params))
        .setOnCompleteListener(new OnCompleteListener() {

            @Override
            public void onComplete(Bundle values,
                FacebookException error) {
                if (error == null) {
                    // When the story is posted, echo the success
                    // and the post Id.
                    final String postId = values.getString("post_id");
                    if (postId != null) {
                        Toast.makeText(getActivity(),
                            "Posted story, id: "+postId,
                            Toast.LENGTH_SHORT).show();
                    } else {
                        // User clicked the Cancel button
                        Toast.makeText(getActivity().getApplicationContext(), 
                            "Publish cancelled", 
                            Toast.LENGTH_SHORT).show();
                    }
                } else if (error instanceof FacebookOperationCanceledException) {
                    // User clicked the "x" button
                    Toast.makeText(getActivity().getApplicationContext(), 
                        "Publish cancelled", 
                        Toast.LENGTH_SHORT).show();
                } else {
                    // Generic, ex: network error
                    Toast.makeText(getActivity().getApplicationContext(), 
                        "Error posting story", 
                        Toast.LENGTH_SHORT).show();
                }
            }

        })
        .build();
    feedDialog.show();
}