如何张贴在Facebook上墙使用Facebook的Andr​​oid SDK中,而无需打开对话框 [英] How to post on facebook wall using Facebook android SDK, without opening dialog box

查看:85
本文介绍了如何张贴在Facebook上墙使用Facebook的Andr​​oid SDK中,而无需打开对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Facebook的SDK,并以实例的帮助下与SDK给我开发了一个code登录并保存access_token到数据库

I am using facebook sdk and with the help of example given with that SDK i developed a code to login and store access_token into database

我有2个问题:

1)。当我尝试从数据库中获取access_token,并把它传递给Facebook它不会让我张贴在墙上使用与Facebook的SDK给定的那个例子,为什么会这样?

1). when i try to fetch access_token from database and pass it to facebook it doesn't allow me to post on wall using that example given with that facebook sdk, why is that so??

2)。我走过了facebook.java code,但我得到的是张贴在墙上我得打开一个对话框,因为是通过我的消息,马上和后没有其他方法。请告诉我朝它或电话我笏应该怎么做时,我想张贴在墙上,而无需打开一个对话框解决方案

2). i gone through that facebook.java code, but what i got is that to post on a wall i got to open a dialogue box as there is no other method to pass my message straight away and post. Please tell me solution towards it or tel me wat should i do when i want to post on a wall without opening a dialogue box

   mPostButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                String message = "Post this to my wall";

                Bundle params = new Bundle();             

                params.putString("message", message);

                mAsyncRunner.request("me/feed", params, "POST", new WallPostRequestListener());

            }
        });

 public class WallPostRequestListener extends BaseRequestListener {

        public void onComplete(final String response) {
            Log.d("Facebook-Example", "Got response: " + response);
            String message = "<empty>";
            try {
                JSONObject json = Util.parseJson(response);
                message = json.getString("message");
            } catch (JSONException e) {
                Log.w("Facebook-Example", "JSON Error in response");
            } catch (FacebookError e) {
                Log.w("Facebook-Example", "Facebook Error: " + e.getMessage());
            }
            final String text = "Your Wall Post: " + message;
            Example.this.runOnUiThread(new Runnable() {
                public void run() {
                    mText.setText(text);
                }
            });
        }
    }

请告诉我错了上述code ..它不是张贴在墙上,给我的墙后:空的手机和模拟器既

Whats wrong with above code.. its not posting on wall and giving me Wall Post: empty on phone and emulator both

在此先感谢。

推荐答案

我申请以下code和能够成功地张贴了我的消息在墙壁上。

i applied following code and could successfully posted my message on wall.

public void postOnWall(String msg) {
        Log.d("Tests", "Testing graph API wall post");
         try {
                String response = mFacebook.request("me");
                Bundle parameters = new Bundle();
                parameters.putString("message", msg);
                parameters.putString("description", "test test test");
                response = mFacebook.request("me/feed", parameters, 
                        "POST");
                Log.d("Tests", "got response: " + response);
                if (response == null || response.equals("") || 
                        response.equals("false")) {
                   Log.v("Error", "Blank response");
                }
         } catch(Exception e) {
             e.printStackTrace();
         }
    }

这篇关于如何张贴在Facebook上墙使用Facebook的Andr​​oid SDK中,而无需打开对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆