1

奇怪的是,我使用正确的代码与预定义的内容进行对话。但它不起作用:(如果我错了,请指导我,谢谢

代码:

    Bundle params = new Bundle();
    params.putString("message", "Predef Message");

    Facebook facebook = new Facebook("APP_ID");
    facebook.dialog(this, "feed", params, new DialogListener(){

        @Override
        public void onComplete(Bundle values) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onFacebookError(FacebookError e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onError(DialogError e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onCancel() {
            return;

        }});
4

2 回答 2

0

我发现我们无法预定义要在墙上发布的消息,请检查此https://developers.facebook.com/docs/reference/androidsdk/dialog/它需要用户交互

在墙上发布消息、共享链接或任何其他需要用户交互的信息。因此,一种解决方法是共享一个链接并为其添加描述:)

于 2012-09-20T10:46:25.797 回答
0

试试这个对我有用

public void postfb() {
    Log.i("PostFB", "POST FB ENTERED..!!");
    Facebook facebook;
    // facebook = new Facebook(InfrqncyApplication.APP_ID);
    facebook = new Facebook(APP_ID);
    // replace APP_API_ID with your own
    facebook.authorize(getActivity(), new String[] { "publish_stream",
            "offline_access" }, null);

    Bundle params = new Bundle();
    params.putString("link", imagePostPath);
    params.putString("name", etxtTitle.getText().toString().trim());
    // params.putString("caption","Via Sharesi.es");
    params.putString("description", etxtDescription.getText().toString());
    params.putString("picture", imagePostPath);

    facebook.dialog(getActivity(), "stream.publish", params,
            new DialogListener() {
                @Override
                public void onComplete(Bundle values) {
                    final String postId = values.getString("post_id");
                    if (postId != null) {
                        Toast.makeText(getActivity(),
                                "Posted sucessfully !", Toast.LENGTH_SHORT)
                                .show();
                        AddPost();
                    } else {
                        Log.d("FB Sample App", "Canceled by User");
                    }
                }

                @Override
                public void onFacebookError(FacebookError error) {

                    AddPost();
                    Log.e("fb", "fb error" + error);
                }

                @Override
                public void onError(DialogError e) {

                    AddPost();
                    Log.e("fb", "fb dialog error" + e.getLocalizedMessage());
                }

                @Override
                public void onCancel() {
                    AddPost();
                }

            });

}
于 2015-05-15T06:55:18.563 回答