/*
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 weibo4android;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import weibo4android.http.AccessToken;
import weibo4android.http.HttpClient;
import weibo4android.http.ImageItem;
import weibo4android.http.PostParameter;
import weibo4android.http.RequestToken;
import weibo4android.http.Response;
import weibo4android.org.json.JSONException;
import weibo4android.org.json.JSONObject;
import weibo4android.util.URLEncodeUtils;
/**
* A java reporesentation of the <a href="http://open.t.sina.com.cn/wiki/">Weibo API</a>
* @editor sinaWeibo
*/
/**
* @author sinaWeibo
*
*/
public class Weibo extends WeiboSupport implements java.io.Serializable {
public static String CONSUMER_KEY = "2495469758";
public static String CONSUMER_SECRET = "710ca831193b916ee85218af21ad6e55";
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;
//----------------------------收藏接口----------------------------------------
/**
* 获取当前用户的收藏列表
* @param page the number of page
* @return List<Status>
* @throws WeiboException when Weibo service or network is unavailable
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites">favorites </a>
* @since Weibo4J 1.2.1
*/
public List<Status> getFavorites(int page) throws WeiboException {
return Status.constructStatuses(get(getBaseURL() + "favorites.json", "page", String.valueOf(page), true));
}
/**
* 收藏一条微博消息
* @param id the ID of the status to favorite
* @return Status
* @throws WeiboException when Weibo service or network is unavailable
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites/create">favorites/create </a>
*/
public Status createFavorite(long id) throws WeiboException {
return new Status(http.post(getBaseURL() + "favorites/create/" + id + ".json", true));
}
/**
* 删除微博收藏.注意:只能删除自己收藏的信息
* @param id the ID of the status to un-favorite
* @return Status
* @throws WeiboException when Weibo service or network is unavailable
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites/destroy">favorites/destroy </a>
*/
public Status destroyFavorite(long id) throws WeiboException {
return new Status(http.post(getBaseURL() + "favorites/destroy/" + id + ".json", true));
}
/**
* 批量删除微博收藏
* @param ids 要删除的一组已收藏的微博消息ID,用半角逗号隔开,一次提交最多提供20个ID
* @return Status
* @throws WeiboException
* @Ricky
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites/destroy_batch">favorites/destroy_batch</a>
* @since Weibo4J 1.2.1
*/
public List<Status> destroyFavorites(String ids)throws WeiboException{
return Status.constructStatuses(http.post(getBaseURL()+"favorites/destroy_batch.json",
new PostParameter[]{new PostParameter("ids",ids)},true));
}
public List<Status> destroyFavorites(String...ids)throws WeiboException{
StringBuilder sb = new StringBuilder();
for(String id : ids) {
sb.append(id).append(',');
}
sb.deleteCharAt(sb.length() - 1);
return Status.constructStatuses(http.post(getBaseURL()+"favorites/destroy_batch.json",
new PostParameter[]{new PostParameter("ids",sb.toString())},true));
}
//----------------------------账号接口 ----------------------------------------
/**
* 验证当前用户身份是否合法
* @return user
* @since Weibo4J 1.2.1
* @throws WeiboException when Weibo service or network is unavailable
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Account/verify_credentials">account/verify_credentials </a>
*/
public User verifyCredentials() throws WeiboException {
/*return new User(get(getBaseURL() + "account/verify_credentials.xml"
, true), this);*/
return new User(get(getBaseURL() + "account/verify_credentials.json"
, true).asJSONObject());
}
/**
* 更改资料 该接口需要申请权限方可调用
* @param name Optional. Maximum of 20 characters.
* @param email Optional. Maximum of 40 characters. Must be a valid email address.
* @param url Optional. Maximum of 100 characters. Will be prepended with "http://" if not present.
* @param location Optional. Maximum of 30 characters. The contents are not normalized or geocoded in any way.
* @param description Optional. Maximum of 160 characters.
* @return the updated user
* @throws WeiboException when Weibo service or network is unavailable
* @since Weibo4J 1.2.1
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Account/update_profile">account/update_profile </a>
*/
public User updateProfile(String name, String email, String url
, String location, String description) throws WeiboException {
List<PostParameter> profile = new ArrayList<PostParameter>(5);
addParameterToList(profile, "name", name);
addParameterToList(profile, "email", email);
addParameterToList(profile, "url", url);
addParameterToList(profile, "location", location);
addParameterToList(profile, "description", description);
return new User(http.post(getBaseURL() + "account/update_profile.json"
, profile.toArray(new PostParameter[profile.size()]), true).asJSONObject());
}
/**
* 更改头像 该接口需要申请权限方可调用
* @param image
* @return
* @throws WeiboException
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Account/update_profile_image">account/update_profile_image</a>
*/
public User updateProfileImage(File image)throws WeiboException {
return new User(http.multPartURL("image",getBaseURL() + "account/update_profile_image.json",
new PostParameter[]{new PostParameter("source",CONSUMER_KEY)},image, true).asJSONObject());
}
/**
*获取当前用户API访问频率限制<br>
* @return the rate limit status
* @throws WeiboException when Weibo service or network is unavailable
* @since Weibo4J 1.2.1
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Account/rate_limit_status">account/rate_limit_status </a>
*/
public RateLimitStatus rateLimitStatus() throws WeiboException {
return new Rate
没有合适的资源?快使用搜索试试~ 我知道了~
Android新浪微博_WebView_Oauth
共146个文件
class:73个
java:58个
xml:5个
4星 · 超过85%的资源 需积分: 15 278 下载量 109 浏览量
2011-10-10
10:47:21
上传
评论 4
收藏 662KB RAR 举报
温馨提示
Android新浪微博,通过WebView来截取授权验证码 ~~~~ Android新浪微博,通过WebView来截取授权验证码 ~~~~
资源推荐
资源详情
资源评论
收起资源包目录
Android新浪微博_WebView_Oauth (146个子文件)
proguard.cfg 1KB
Weibo.class 56KB
HttpClient.class 26KB
Test.class 21KB
JSONObject.class 20KB
HTMLEntity.class 18KB
User.class 13KB
JSONArray.class 12KB
Status.class 10KB
OAuth.class 10KB
Comment.class 9KB
Configuration.class 8KB
WeiboResponse.class 8KB
Response.class 7KB
Query.class 7KB
XML.class 7KB
JSONML.class 7KB
Tag.class 6KB
PostParameter.class 6KB
Trends.class 6KB
JSONTokener.class 6KB
SearchResult.class 5KB
XMLTokener.class 5KB
Emotion.class 5KB
CDL.class 4KB
SavedSearch.class 4KB
IDs.class 4KB
JSONWriter.class 4KB
Count.class 4KB
FileType.class 4KB
AuthorizationAct.class 4KB
UserTrend.class 4KB
RateLimitStatus.class 3KB
MainActivity.class 3KB
Cookie.class 3KB
WeiboSupport.class 3KB
OAuthToken.class 3KB
Paging.class 3KB
AuthorizationAct$WebViewC.class 3KB
ImageItem.class 3KB
OAuthActivity$1.class 3KB
HTTP.class 3KB
OAuthActivity.class 3KB
RequestToken.class 2KB
BareBonesBrowserLaunch.class 2KB
BASE64Encoder.class 2KB
CookieList.class 2KB
OAuthConstant.class 2KB
URLEncodeUtils.class 2KB
Test$1Obj.class 2KB
Trend.class 2KB
HttpClient$ByteArrayPart.class 2KB
UserWapper.class 1KB
AccessToken.class 1KB
HttpClient$3.class 1KB
WeiboException.class 1KB
Gender.class 1KB
HTTPTokener.class 1KB
Response$1.class 1KB
JSONObject$Null.class 849B
HttpClient$2.class 772B
HttpClient$1.class 754B
JSONException.class 715B
JSONStringer.class 646B
R.class 573B
R$id.class 565B
R$layout.class 484B
Version.class 470B
Constants.class 463B
Weibo$Device.class 451B
R$string.class 445B
R$drawable.class 418B
R$attr.class 358B
JSONString.class 170B
.classpath 518B
commons-httpclient-3.1.jar 298KB
commons-logging-1.1.jar 52KB
commons-codec.jar 46KB
Weibo.java 154KB
JSONObject.java 51KB
HttpClient.java 36KB
JSONArray.java 29KB
Test.java 29KB
HTMLEntity.java 27KB
OAuth.java 16KB
User.java 15KB
JSONML.java 15KB
XML.java 14KB
JSONTokener.java 12KB
Configuration.java 12KB
Status.java 11KB
XMLTokener.java 10KB
JSONWriter.java 10KB
Response.java 10KB
CDL.java 9KB
WeiboResponse.java 9KB
Comment.java 8KB
PostParameter.java 7KB
WeiboSupport.java 7KB
Query.java 7KB
共 146 条
- 1
- 2
forever_crying
- 粉丝: 126
- 资源: 41
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页