According to the Sina Open forum some Netizen's introduction, first login needs to enter PIN code, generate Accesstoken data, save, can stay for two times login use, I provide examples of Java SDK to modify and test through.
Write a class Saveaccesstoken.java that provides save and read Accesstoken data.
Modifying Oauthupdate.java as a test
Get authorization code for the first time:
Access to Sina interface:
To save Accesstoken data to a file:
Two login:
Class Saveaccesstoken.java Introduction: Saving and reading Accesstoken data
Save Accesstoken Data
public static void Save (Accesstoken _accesstoken) throws ioexception{
try {
Properties = new properties ();
Property.setproperty ("Accesstoken", _accesstoken.gettoken ());
Property.setproperty ("Accesstokensecret", _accesstoken.gettokensecret ());
Property.store (New FileOutputStream ("Mysave.properties"), "mysave.properties");
System.out.println ("Successfully Save Access Token");
catch (Exception e) {
E.printstacktrace ();
}
}
Reading Accesstoken Data
public static Accesstoken Read (String _filename) throws ioexception{
try {
Properties = new properties ();
Accesstoken accesstoken = null;
Property.load (New FileInputStream (_filename));
Accesstoken _accesstoken=new Accesstoken (Property.getproperty ("Accesstoken"), Property.getproperty (" Accesstokensecret "));
System.out.println ("Successfully Read Access Token");
return _accesstoken;
catch (Exception e) {
E.printstacktrace ();
return null;
}
}
Oauthupdate.java as a test class, modify the Sina Weibo Java SDK with test class
http://download.csdn.net/source/3481549