/*
Copyright (c) 2007-2009, Yusuke Yamamoto
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Yusuke Yamamoto nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package weibo4j;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import weibo4j.http.AccessToken;
import weibo4j.http.HttpClient;
import weibo4j.http.ImageItem;
import weibo4j.http.PostParameter;
import weibo4j.http.RequestToken;
import weibo4j.http.Response;
import weibo4j.org.json.JSONException;
import weibo4j.org.json.JSONObject;
/**
* A java reporesentation of the <a href="http://open.t.sina.com.cn/wiki/">Weibo API</a>
*/
public class Weibo extends WeiboSupport implements java.io.Serializable {
public static String CONSUMER_KEY = "2878322676";
public static String CONSUMER_SECRET = "a9aea622b70b1b41521577016de7b56c";
private String baseURL = Configuration.getScheme() + "api.t.sina.com.cn/";
private String searchBaseURL = Configuration.getScheme() + "api.t.sina.com.cn/";
private static final long serialVersionUID = -1486360080128882436L;
public Weibo() {
super();
format.setTimeZone(TimeZone.getTimeZone("GMT"));
http.setRequestTokenURL(Configuration.getScheme() + "api.t.sina.com.cn/oauth/request_token");
http.setAuthorizationURL(Configuration.getScheme() + "api.t.sina.com.cn/oauth/authorize");
http.setAccessTokenURL(Configuration.getScheme() + "api.t.sina.com.cn/oauth/access_token");
}
/**
* Sets token information
* @param token
* @param tokenSecret
*/
public void setToken(String token, String tokenSecret) {
http.setToken(token, tokenSecret);
}
public Weibo(String baseURL) {
this();
this.baseURL = baseURL;
}
public Weibo(String id, String password) {
this();
setUserId(id);
setPassword(password);
}
public Weibo(String id, String password, String baseURL) {
this();
setUserId(id);
setPassword(password);
this.baseURL = baseURL;
}
/**
* Sets the base URL
*
* @param baseURL String the base URL
*/
public void setBaseURL(String baseURL) {
this.baseURL = baseURL;
}
/**
* Returns the base URL
*
* @return the base URL
*/
public String getBaseURL() {
return this.baseURL;
}
/**
* Sets the search base URL
*
* @param searchBaseURL the search base URL
* @since Weibo4J 1.1220
*/
public void setSearchBaseURL(String searchBaseURL) {
this.searchBaseURL = searchBaseURL;
}
/**
* Returns the search base url
* @return search base url
* @since Weibo4J 1.1220
*/
public String getSearchBaseURL(){
return this.searchBaseURL;
}
/**
*
* @param consumerKey OAuth consumer key
* @param consumerSecret OAuth consumer secret
* @since Weibo4J 1.1220
*/
public synchronized void setOAuthConsumer(String consumerKey, String consumerSecret){
this.http.setOAuthConsumer(consumerKey, consumerSecret);
}
/**
* Retrieves a request token
* @return generated request token.
* @throws WeiboException when Weibo service or network is unavailable
* @since Weibo4J 1.1220
* @see <a href="http://oauth.net/core/1.0/#auth_step1">OAuth Core 1.0 - 6.1. Obtaining an Unauthorized Request Token</a>
*/
public RequestToken getOAuthRequestToken() throws WeiboException {
return http.getOAuthRequestToken();
}
public RequestToken getOAuthRequestToken(String callback_url) throws WeiboException {
return http.getOauthRequestToken(callback_url);
}
/**
* Retrieves an access token assosiated with the supplied request token.
* @param requestToken the request token
* @return access token associsted with the supplied request token.
* @throws WeiboException when Weibo service or network is unavailable, or the user has not authorized
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Oauth/access_token">Oauth/access token </a>
* @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2. Obtaining User Authorization</a>
* @since Weibo4J 1.1220
*/
public synchronized AccessToken getOAuthAccessToken(RequestToken requestToken) throws WeiboException {
return http.getOAuthAccessToken(requestToken);
}
/**
* Retrieves an access token assosiated with the supplied request token and sets userId.
* @param requestToken the request token
* @param pin pin
* @return access token associsted with the supplied request token.
* @throws WeiboException when Weibo service or network is unavailable, or the user has not authorized
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Oauth/access_token">Oauth/access token </a>
* @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2. Obtaining User Authorization</a>
* @since Weibo4J 1.1220
*/
public synchronized AccessToken getOAuthAccessToken(RequestToken requestToken, String pin) throws WeiboException {
AccessToken accessToken = http.getOAuthAccessToken(requestToken, pin);
setUserId(accessToken.getScreenName());
return accessToken;
}
/**
* Retrieves an access token assosiated with the supplied request token and sets userId.
* @param token request token
* @param tokenSecret request token secret
* @return access token associsted with the supplied request token.
* @throws WeiboException when Weibo service or network is unavailable, or the user has not authorized
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Oauth/access_token">Oauth/access token </a>
* @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2. Obtaining User Authorization</a>
* @since Weibo4J 1.1220
*/
public synchronized AccessToken getOAuthAccessToken(String token, String tokenSecret) throws WeiboException {
AccessToken accessToken = http.getOAuthAccessToken(token, tokenSecret);
setUserId(accessToken.getScreenName());
return accessToken;
}
/**
* Retrieves an access token assosiated with the supplied request token.
* @param token request token
* @param tokenSecret request token secret
* @param oauth_verifier oauth_verifier or pin
* @return access to
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于Android的新浪微博系统开发01-开发概述 基于Android的新浪微博系统开发02-下载微博sdk 基于Android的新浪微博系统开发03-微博客户端主架构 基于Android的新浪微博系统开发04-微博客户端主架构 基于Android的新浪微博系统开发05-主UI设计 基于Android的新浪微博系统开发主06-主UI完善 基于Android的新浪微博系统开发07-不断扩展的ListView 基于Android的新浪微博系统开发08-动态获取Icon和局部TextVieww
资源推荐
资源详情
资源评论
收起资源包目录
2011年沈大海讲师Android的新浪微博客户端源代码 (674个子文件)
resources.ap_ 482KB
weibo1123.apk 858KB
Weibo.class 57KB
AsyncWeibo.class 32KB
HttpClient.class 24KB
Test.class 20KB
JSONObject.class 18KB
HTMLEntity.class 18KB
R$string.class 16KB
User.class 16KB
R$drawable.class 12KB
WeiboTest.class 11KB
JSONArray.class 11KB
R$id.class 10KB
Status.class 10KB
OAuth.class 9KB
MainService.class 9KB
WeiboStream.class 8KB
Configuration.class 8KB
ListObject.class 8KB
Comment.class 8KB
WeiboResponse.class 7KB
Response.class 7KB
WeiboAdapter.class 7KB
UserInfoActivity.class 7KB
WeiboStatusActivity.class 6KB
DirectMessage.class 6KB
XML.class 6KB
JSONML.class 6KB
PostParameter.class 6KB
RetweetDetails.class 5KB
Tag.class 5KB
Trends.class 5KB
QueryResult.class 5KB
JSONTokener.class 5KB
Query.class 4KB
Tweet.class 4KB
XMLTokener.class 4KB
HomeActivity.class 4KB
SavedSearch.class 4KB
CDL.class 4KB
IDs.class 4KB
FileType.class 4KB
JSONWriter.class 4KB
WeiboSupport.class 3KB
WeiboStream$StreamHandlingThread.class 3KB
RateLimitStatus.class 3KB
CamerActivity.class 3KB
Cookie.class 3KB
Paging.class 3KB
Count.class 3KB
OAuthToken.class 3KB
CommentActivity.class 3KB
ListUserCount.class 3KB
HTTP.class 2KB
Dispatcher.class 2KB
MSGActivity.class 2KB
MyAdapter.class 2KB
WeiboListener.class 2KB
TextViewLink.class 2KB
NetUtil.class 2KB
RequestToken.class 2KB
BASE64Encoder.class 2KB
NewWeiboActivity.class 2KB
LoginListAdapter.class 2KB
Trend.class 2KB
LoginActivity.class 2KB
Test$1Obj.class 2KB
CookieList.class 2KB
StatusStream.class 2KB
SearchActivity.class 2KB
DirectMsgAdapter.class 2KB
MoreActivity.class 2KB
MsgAdapter.class 2KB
CamerActivity$SurfaceCallback.class 2KB
MainService$1.class 2KB
OAuthReadUtil.class 2KB
GPSPoint.class 2KB
HttpClient$ByteArrayPart.class 1KB
MainActivity.class 1KB
BaseLoginReadUtil.class 1KB
ListObjectWapper.class 1KB
R$layout.class 1KB
UserWapper.class 1KB
Task.class 1KB
DateUtil.class 1KB
AsyncWeibo$97.class 1KB
AccessToken.class 1KB
AsyncWeibo$94.class 1KB
ImageItem.class 1KB
ExecuteThread.class 1KB
AsyncWeibo$16.class 1KB
WeiboException.class 1KB
HttpClient$3.class 1KB
AsyncWeibo$17.class 1KB
AsyncWeibo$8.class 1KB
AsyncWeibo$68.class 1KB
AsyncWeibo$53.class 1KB
AsyncWeibo$96.class 1KB
AsyncWeibo$6.class 1KB
共 674 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
sdhjob
- 粉丝: 1338
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页