1. First download the relevant code of Sina Weibo. I will experience the idea weibo4j-oauth2-beta2.0.zip. Unzip the code and import it directly to eclipse. It is best to change your application to Web
2. Need to open the microblog platform registration information, address: http://open.weibo.com/
A. Click-> Create an application. There are three types of applications: Intra-site applications, client applications, and others.
B. Select intra-site application here. I have not tried any other applications.
C. You can easily enter the information for creating an application on the site. It is best not to bind a domain name, which saves configuration effort.
3. Click my application after the application is created. You will find the application you have created. Pay special attention to the following:
APP key :***
APP secret :***
Site Application address: Refers to your application in Sina Weibo corresponding address entry: http://apps.weibo.com/dfdfddss
Actual Application address: Actually the application address you created locally http: // 192.168.14.32: 8080/websina/accesstoken. Do
4. Go back to eclipse and pay attention to config. properties.
Client_id = app key
Client_sercret = app secret
Redirect_uri = actual application address
5. Enter the following address in the address bar:
Https://api.weibo.com/oauth2/authorize? Client_id = client_id & redirect_uri = redirect_uri & response_type = Code
Then go to the Sina Weibo authorization page. At this time, Sina Weibo will return a verification code in the form of an address. Your account with this authentication code will be recognized by Weibo.
Or
Oauth = new oauth ();
Barebonesbrowserlaunch. Openurl (oauth. Authorize ("Code"); // This is a method provided by Sina Weibo to open a browser.
Eg: http://apps.weibo.com/ffsferwer? Code = &&&
Then use the code
Oauth = new oauth ();
// Return code
String code = request. getparameter ("Code ");
Accesstoken = oauth. getaccesstokenbycode (CODE); // obtain the value of that Code
Then pass
Weibo = new Weibo ();
Weibo. settoken (accesstoken. getaccesstoken ());
Timeline TM = new timeline ();
Status status = TM. updatestatus (statuses );
Note: I used to write the actual address of the application as a formal address. Then I found out, how can I get the returned code? So this is definitely not correct. Fortunately, I saw this article. Thank you very much for the author of this article. Source http://ganliang13.iteye.com/blog/1501842