如何在Facebook上分享文本通过Android应用程序登录,通过Facebook Parse登录

时间:2014-06-26 05:55:31

标签: android facebook parse-platform facebook-sharer

我正在努力将facebook功能的分享添加到我的应用中。我有facebook的新版本的解析sdk。

我似乎无法找到有关如何使用parse的fb sdk来实现共享的信息。

我在我的应用程序中打开了facebook会话,但不明白如何在android上发布文本或在facebook上分享文本。

请给我任何建议。

提前致谢...

1 个答案:

答案 0 :(得分:0)

我得到了ans:)

这是解决方案:

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();