简体   繁体   中英

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. This is my code public class CondividiSuFacebookActivity extends 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.

Posting on facebook wall with sdk 3.0

Please ensure you read the answer to the question for the complete solution. The code in the question asked should still help you out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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