/*
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 = "2619679889";
public static String CONSUMER_SECRET = "e186852236369354a7761274fc458eba";
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;
//----------------------------微博搜索 API------------------------------------
/**
* 搜索微博用户 (仅对新浪合作开发者开放)
* @param query
* @return a list of User
* @throws WeiboException
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Users/search">users/search </a>
*/
public List<User> searchUser(Query query) throws WeiboException {
return User.constructUsers(get(searchBaseURL + "users/search.json",
query.getParameters(), false));
}
/**
* 搜索微博文章 (仅对新浪合作开发者开放)
* @param query
* @return
* @throws WeiboException
*/
public List<SearchResult> search(Query query) throws WeiboException {
return SearchResult.constructResults(get(searchBaseURL + "search.json", query.getParameters(), true));
}
/**
* 搜索微博(多条件组合) (仅对合作开发者开放)
* @param query
* @return a list of statuses
* @throws WeiboException
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/search">Statuses/search
*/
public List<Status> statussearch(Query query) throws WeiboException{
return Status.constructStatuses(get(searchBaseURL + "statuses/search.json", query.getParameters(), true));
}
//----------------------------收藏接口----------------------------------------
/**
* 获取当前用户的收藏列表
* @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.0
*/
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.0
*/
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.0
* @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.0
* @see <a href="http://open.t.sina.com.cn/wiki/index.php/Accoun
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
新浪微博Android视频教程第10讲源码:用户登录1 (215个子文件)
resources.ap_ 247KB
myweibo.apk 519KB
proguard.cfg 1KB
Weibo.class 58KB
HttpClient.class 26KB
Test.class 21KB
JSONObject.class 20KB
HTMLEntity.class 18KB
User.class 16KB
JSONArray.class 12KB
Status.class 11KB
OAuth.class 10KB
Comment.class 8KB
Configuration.class 8KB
WeiboResponse.class 8KB
Response.class 7KB
Query.class 7KB
XML.class 7KB
JSONML.class 7KB
Tag.class 6KB
PostParameter.class 6KB
RetweetDetails.class 6KB
Trends.class 6KB
JSONTokener.class 6KB
UserInfoServices.class 5KB
SearchResult.class 5KB
XMLTokener.class 5KB
Emotion.class 5KB
CDL.class 4KB
SavedSearch.class 4KB
IDs.class 4KB
JSONWriter.class 4KB
FileType.class 4KB
Count.class 4KB
MainService.class 4KB
WebViewActivity.class 4KB
UserTrend.class 4KB
RateLimitStatus.class 3KB
Cookie.class 3KB
WeiboSupport.class 3KB
AccessTokenActivity.class 3KB
OAuthToken.class 3KB
Paging.class 3KB
ImageItem.class 3KB
RequestToken.class 3KB
HTTP.class 3KB
BareBonesBrowserLaunch.class 2KB
UserInfo.class 2KB
LoginActivity.class 2KB
BASE64Encoder.class 2KB
AuthUtil.class 2KB
CookieList.class 2KB
URLEncodeUtils.class 2KB
Test$1Obj.class 2KB
AccessToken.class 2KB
Trend.class 2KB
TextAutoLink.class 2KB
WebViewActivity$2.class 2KB
UserInfoAdapter.class 2KB
HttpClient$ByteArrayPart.class 2KB
LogoActivity.class 1KB
UserWapper.class 1KB
AuthActivity.class 1KB
MainService$1.class 1KB
JavascriptInterface.class 1KB
LogoActivity$1.class 1KB
LoginActivity$UserSelectedOnClickListener.class 1KB
Task.class 1KB
HttpClient$3.class 1KB
DBHelper.class 1KB
WeiboException.class 1KB
Gender.class 1KB
HTTPTokener.class 1KB
R$drawable.class 1KB
Response$1.class 1KB
AuthActivity$1.class 1KB
WebViewActivity$1.class 989B
WebViewActivity$3.class 989B
WebViewActivity$4.class 930B
JSONObject$Null.class 849B
HttpClient$2.class 772B
HttpClient$1.class 754B
R$id.class 732B
DBInfo$Table.class 718B
JSONException.class 715B
R$string.class 686B
R.class 663B
JSONStringer.class 646B
R$layout.class 606B
R$style.class 494B
DBInfo$DB.class 485B
Version.class 470B
Constants.class 463B
Weibo$Device.class 451B
R$color.class 433B
DBInfo.class 432B
R$attr.class 352B
IWeiboActivity.class 199B
JSONString.class 170B
.classpath 475B
共 215 条
- 1
- 2
- 3
资源评论
- qq_312325692015-09-16对学习有一定的帮助
- huangf7f82014-06-21感觉帮助不是很大
- dengdaip2015-11-12收获一般,不过还是学到了很多东西,毕竟是菜鸟
罪爱
- 粉丝: 44
- 资源: 25
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功