After passing the previous authentication, you can call the open APIs in the API. Generally, the applications we develop need to display Weibo information of some enterprises. For example, the MasterCard I developed previously showed MasterCard Weibo.
First, we need to call an interface: callback
Now Sina has changed to interfaces with S, but it still does not feel that S is easy to use. Many examples on the Internet call interfaces without S, and I call interfaces with S, I don't know the reason. If you know the reason, please tell your younger brother. I also use it here.
Note that:
Generally, we query Weibo Based on screen_name settings.
Code snippet:
Oauthconsumer authconsumer = new commonshttpoauthconsumer (oauth. consumerkey, oauth. consumersecret); authconsumer. settokenwithsecret (user. token, user. tokensecret); here we can also pass the authconsumer during the previous oauth authentication, so we don't need to use these steps. Client = new defaulthttpclient (); httppost = new httppost (user_timeline_url ); // There are many attributes such as page and count. Check the API. list <namevaluepair> List = new arraylist <namevaluepair> (); list. add (New basicnamevaluepair ("screen_name", "MasterCard"); httppost. setentity (New urlencodedformentity (list, HTTP. utf_8); httppost. getparams (). setbooleanparameter (coreprotocolpnames. use_expect_continue, false); authconsumer. sign (httppost); httpresponse = client.exe cute (httppost); If (httpstatus. SC _ OK = httpresponse. getstatusline (). getstatuscode () {string result = entityutils. tostring (httpresponse. getentity (); log. I (oauth. tag, result );}
In this way, we can get the Weibo information we want.
Shown as follows: (MasterCard is displayed)
Being developed, it looks ugly. If you don't have time to adjust it, you will be there.