Java Implementation Sina microblogging API interface to play Sina Weibo (ii)

Source: Internet
Author: User

In your application profile, find your key app key and app Secret. The second is to fill in the advanced information of the application of the authorization callback page and cancel the URL of the callback page, this can be your own local Web application URL or a valid URL on the network (can be http://www.baidu.com), note that this URL must not be at the end of the

All this information needs to be completed.

To Http://open.weibo.com/wiki/SDK the SDK needed, here is the Java example: you can download to the http://code.google.com/p/weibo4j/directly to the desired javasdk.

Download it and then pour it into your editing tool (Eclipse or MyEclipse) as shown:


Edit the Config.properties file and fill out the client_id =app Key Client_sercret=app_secret redirect_uri= The authorization callback URL that you just filled out in the application's advanced information. After you fill it out, OK to save it.

Then run the Oauth4code class under the Weibo4j.examples.oauth2 package below examples, where you will see http://********/?code=**************** in the URL of your callback page , the address information before the code is the URL of the callback you filled in, and the code behind is the key. You go to see the console information, is waiting for you to enter the code value, you only need to paste the code value to the console, press the Enter button, will show a lot of information about your microblog. Then note the value of the last line that appears access_token. With this access_token value, you can do all the things you want to do, including posting Sina Weibo and so on.

And look back at the UpdateStatus class below the example Weibo4j.examples.timeline bag.

String access_token= "2.001gkuccdjzabebcc4a40cc36fj6lb";
		String statuses = "As long as a access_token, you are enough to play Sina Weibo, oyea~~";  
		Weibo Weibo = new Weibo ();
		Weibo.settoken (Access_token);
		Timeline TM = new Timeline ();
		try {
			Status status = TM. UpdateStatus (statuses);
			Log.loginfo (Status.tostring ());
		} catch (Weiboexception e) {
			e.printstacktrace ();
		}	
		}

Take a look and see if your Sina Weibo has posted the message ~~~~~



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.