简体   繁体   English

Android-如何使用Facebook 3.0 SDK发布状态

[英]Android - How to post a state with Facebook 3.0 SDK

With the Facebook SDK examples I'm able to login with Facebook, but now I need to post a message on the wall, I don't understand how to do this. 通过Facebook SDK示例,我可以使用Facebook登录,但是现在我需要在墙上张贴一条消息,我不知道该怎么做。 This is my code public class CondividiSuFacebookActivity extends Activity{ 这是我的代码公共类CondividiSuFacebookActivity扩展Activity {

  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.facebook_condividi);


      String msg = (String)getIntent().getStringExtra("message");


      // start Facebook Login
      Session.openActiveSession(this, true, new Session.StatusCallback() 
      {

          // callback when session changes state

          public void call(Session session, SessionState state, Exception exception) 
          {
                if (session.isOpened()) 
                {

                    // make request to the /me API
                    Request.executeMeRequestAsync(session, new Request.GraphUserCallback() 
                    {

                        // callback after Graph API response with user object
                        public void onCompleted(GraphUser user, Response response) 
                        {
                            if (user != null) 
                            {
                                TextView welcome = (TextView) findViewById(R.id.welcome);
                                welcome.setText("Hello " + user.getName() + "!");
                            }
                        }
                    });
                }
          }
    });
  }


  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
  }



 }

I have found this function: 我发现了这个功能:

 Request.newStatusUpdateRequest(session, "Hello!", new Request.Callback() {

public void onCompleted(Response response) {
        // TODO Auto-generated method stub

}
 });

But I don't understand how to use it. 但是我不知道如何使用它。 Any suggestions? 有什么建议么? Thanks 谢谢

I suggest you take a look at the following StackOverflow question. 我建议您看一下下面的StackOverflow问题。

Posting on facebook wall with sdk 3.0 使用SDK 3.0在Facebook墙上发布

Please ensure you read the answer to the question for the complete solution. 请确保您阅读问题的答案以获取完整的解决方案。 The code in the question asked should still help you out. 所提问题中的代码仍然可以为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM