/*
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 com.itcast.weibo.sina;
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 com.itcast.net.http.AccessToken;
import com.itcast.net.http.HttpClient;
import com.itcast.net.http.ImageItem;
import com.itcast.net.http.PostParameter;
import com.itcast.net.http.RequestToken;
import com.itcast.net.http.Response;
import com.itcast.net.json.JSONException;
import com.itcast.net.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 = "1521092152";
public static String CONSUMER_SECRET = "b9cf1b1bc4ca3d69c7aaff7e9fb2d28e";
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");
}
public List<Status> getTrendTimeline(String tname) throws
WeiboException {
return Status.constructStatuses(get(
getBaseURL() + "trends/statuses.json?source="
+Weibo.CONSUMER_KEY
+"&trend_name="+tname,true));
//return Status.constructStatuses(get(getBaseURL() + "statuses/friends_timeline.xml",null, paging, true), this);
}
/**
* 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
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
2011年沈大海讲师Android的新浪微博源码2.0更新 (1489个子文件)
README.586 2KB
README.686 1KB
libcurl.a 6.54MB
libxml2.a 3.03MB
libcurl.a 2.79MB
libjpeg.a 1.99MB
libpng.a 867KB
zlib.adb 20KB
test.adb 13KB
zlib-streams.adb 6KB
mtest.adb 4KB
read.adb 4KB
buffer_demo.adb 4KB
zlib-thin.adb 3KB
zlib-thin.ads 15KB
zlib.ads 13KB
zlib-streams.ads 4KB
resources.ap_ 2.22MB
weiboitcast02.apk 3.11MB
Makefile-dynamic.ARM 3KB
Makefile.ARM 2KB
gvmat32.asm 27KB
inffas32.asm 16KB
gvmat64.asm 15KB
match.asm 11KB
inffasx64.asm 10KB
mkasm.bat 127B
bld_ml32.bat 93B
bld_ml64.bat 86B
DotZLib.build 1KB
xmlparse.c 185KB
deflate.c 63KB
unzip.c 48KB
inflate.c 48KB
runtests.c 44KB
xmltok_impl.c 43KB
trees.c 43KB
xmltok.c 40KB
inffas86.c 40KB
zip.c 36KB
puff.c 36KB
xmlrole.c 32KB
gzio.c 30KB
gun.c 25KB
infback.c 22KB
infback9.c 21KB
xmlwf.c 20KB
blast.c 17KB
gzappend.c 16KB
untgz.c 16KB
example.c 16KB
miniunz.c 15KB
zran.c 15KB
gzjoin.c 14KB
inftrees.c 13KB
inftree9.c 13KB
crc32.c 13KB
inffast.c 12KB
minizip.c 11KB
gzlog.c 11KB
fitblk.c 8KB
minigzip.c 8KB
mztools.c 8KB
testzlib.c 7KB
inffas8664.c 7KB
zutil.c 7KB
iowin32.c 6KB
zpipe.c 6KB
xmlfile.c 5KB
adler32.c 4KB
ioapi.c 4KB
minicheck.c 3KB
xmlmime.c 3KB
chardata.c 3KB
xmltok_ns.c 3KB
ct.c 3KB
benchmark.c 2KB
compress.c 2KB
win32filemap.c 2KB
uncompr.c 2KB
outline.c 2KB
gvmat32c.c 2KB
readfilemap.c 1KB
codepage.c 1KB
elements.c 1KB
unixfilemap.c 1KB
zfstream.cc 13KB
test.cc 1KB
ChangeLogUnzip 2KB
DotZLib.chm 71KB
Weibo.class 60KB
AsyncWeibo.class 34KB
HttpClient.class 26KB
Test.class 21KB
JSONObject.class 20KB
HTMLEntity.class 18KB
User.class 17KB
R$string.class 16KB
JSONArray.class 12KB
R$drawable.class 12KB
共 1489 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
sdhjob
- 粉丝: 1338
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 3122080306 邹子轩 实验报告二.docx
- 基于STM32 NUCLEO板设计彩色LED照明灯(纯cubeMX开发)(大赛作品,文档完整,可直接运行)
- 发那科工业机器人保养大全
- Sphere.h
- REMD固有时间尺度分解信号分量可视化(Matlab完整源码和数据)
- 嵌入式系统双单片机STC89C52+STC15W104多功能学习板电路图可扩展 适用于单片机初学者和教学
- 基于STM32蓝牙控制小车系统设计(硬件+源代码+论文)大赛作品
- XILINXFPGA源码基于Spartan3火龙刀系列FPGA开发板VGA测试例程
- Java聊天室的设计与实现【尚学堂·百战程序员】
- python中matplotlib教程
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页