The project in the use of Sina Weibo landing needs, online search for a long time, there is no suitable answer. After half a day's effort, finally finished. For the convenience of peers, special will be detailed steps written out, rough writing, laughed.
First of all, to register Sina Weibo account, after the successful registration, in Http://open.weibo.com/development/mobile Open this link,
Create an application, and after the application is created, edit the application's information in my application
These two sets of data are then used in the generated Appkey and App_secret.
Then in the application information, the basic information and advanced information should be filled in. The authorization callback page for advanced information also needs to be filled in Baidu can also be.
Next you need to add a test account to the application,
In the application information to find the test account and then click Edit, add test account, input is the nickname of the account, you can fill in the account name just registered. After you bind the test account, you will download the Java SDK
The address is Http://open.weibo.com/wiki/SDK after you select the Java SDK download to import Eclipse and then find config.properties fill in Appkey and App_secret
As follows:
client_id = Your Appkey
Client_sercret = Your App_secret
Redirect_uri =http://www.baidu.com
BaseURL = https://api.weibo.com/2/
Accesstokenurl = Https://api.weibo.com/2/oauth2/access_token
Authorizeurl = Https://api.weibo.com/2/oauth2/authorize
Then find the Oauth4code class, which will then eject the authorization page (in the state of your Sina Weibo login) to confirm the authorization. Call the written authorization callback page (Redirect_uri), get the code value, enter the value of the code in Eclipse, and after the console prints the access token and the corresponding UID to token, in the Showuser class The code is as follows:
public class Showuser {public
static void Main (string[] args) {
String Access_token = "token you have taken";
Weibo Weibo = new Weibo ();
Weibo.settoken (Access_token);
String uid = "UID fetched";
Users um = new users ();
try {
User user = Um.showuserbyid (UID);
Log.loginfo (User.tostring ());
} catch (Weiboexception e) {
e.printstacktrace ();}}}
After running, you can output the user's information.