Is anyone interested in making a BlackBerry version of the scarf for Sohu? Use Sohu Weibo API to whisper and whisper

Source: Internet
Author: User

API Description: http://open.t.sohu.com/

Development support: Openapi@sohu-inc.com

Below is an example program that is debugged on a laptop.

If you want to make a BlackBerry version, the code might be a little more complicated. But the same principle, is to go to the HTTP protocol post Weibo data to Sohu.

Dependency Class Library: Commons-codec-1.3.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar

public class Sohublogger {

HttpClient client = new HttpClient ();
String server_update = "Http://api.t.sohu.com/statuses/update.xml";
String USERNAME =cafebabe@xxx.com;
String PASSWORD = "xxx";

public static void Main (string[] args) {
Sohublogger controller = new Sohublogger ();
try {
Controller.postmessage ("Hello World Chinese");
} catch (HttpException e) {
E.printstacktrace ();
} catch (IOException e) {
E.printstacktrace ();
}
}//

public void PostMessage (String msg) throws HttpException, IOException {
Base64encoder decoder = new Base64encoder ();
msg = Decoder.encodebuffer (msg.getbytes ("UTF-8"));

Boolean needauthentication = true;
if (needauthentication) {
Client.getparams (). Setauthenticationpreemptive (True);
Client.getstate (). SetCredentials (
New Authscope (Authscope.any_host, Authscope.any_port, Authscope.any_realm),
New Usernamepasswordcredentials (USERNAME, PASSWORD));
}
Postmethod method = new Utf8postmethod (server_update);

if (needauthentication) {
Method.setdoauthentication (TRUE);
}
Method.addparameter ("status", msg);

Client.executemethod (method);

System.out.println ("Post status:" + Method.getstatusline (). toString ());
System.out.println ("Post page content:"
+ method.getresponsebodyasstring ());

Release any connection resources used by the method
Method.releaseconnection ();
}

}

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.