Get the code returned after Sina Weibo authorization

Source: Internet
Author: User
Tags oauth

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.