2 Copyright (c) 2007-2009, Yusuke Yamamoto
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Yusuke Yamamoto nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY
17 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 package weibo4android
;
30 import java
.text
.SimpleDateFormat
;
31 import java
.util
.ArrayList
;
32 import java
.util
.Date
;
33 import java
.util
.HashMap
;
34 import java
.util
.List
;
35 import java
.util
.Locale
;
37 import java
.util
.TimeZone
;
38 import org
.w3c
.dom
.Document
;
39 import org
.w3c
.dom
.Element
;
40 import weibo4android
.http
.AccessToken
;
41 import weibo4android
.http
.HttpClient
;
42 import weibo4android
.http
.ImageItem
;
43 import weibo4android
.http
.PostParameter
;
44 import weibo4android
.http
.RequestToken
;
45 import weibo4android
.http
.Response
;
46 import weibo4android
.org
.json
.JSONException
;
47 import weibo4android
.org
.json
.JSONObject
;
48 import weibo4android
.util
.URLEncodeUtils
;
51 * A java reporesentation of the <a href="http://open.t.sina.com.cn/wiki/">Weibo API</a>
59 public class Weibo
extends WeiboSupport
implements java
.io
.Serializable
{
60 public static String CONSUMER_KEY
= "222764142";
61 public static String CONSUMER_SECRET
= "087c31deb39cee8622248b3be8150e40";
62 private String baseURL
= Configuration
.getScheme() + "api.t.sina.com.cn/";
63 private String searchBaseURL
= Configuration
.getScheme() + "api.t.sina.com.cn/";
64 private static final long serialVersionUID
= -1486360080128882436L;
66 //----------------------------收藏接口----------------------------------------
70 * @param page the number of page
71 * @return List<Status>
72 * @throws WeiboException when Weibo service or network is unavailable
73 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites">favorites </a>
74 * @since Weibo4J 1.2.1
76 public List
<Status
> getFavorites(int page
) throws WeiboException
{
77 return Status
.constructStatuses(get(getBaseURL() + "favorites.json", "page", String
.valueOf(page
), true));
84 * @param id the ID of the status to favorite
86 * @throws WeiboException when Weibo service or network is unavailable
87 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites/create">favorites/create </a>
89 public Status
createFavorite(long id
) throws WeiboException
{
90 return new Status(http
.post(getBaseURL() + "favorites/create/" + id
+ ".json", true));
94 * 删除微博收藏.注意:只能删除自己收藏的信息
95 * @param id the ID of the status to un-favorite
97 * @throws WeiboException when Weibo service or network is unavailable
98 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites/destroy">favorites/destroy </a>
100 public Status
destroyFavorite(long id
) throws WeiboException
{
101 return new Status(http
.post(getBaseURL() + "favorites/destroy/" + id
+ ".json", true));
106 * @param ids 要删除的一组已收藏的微博消息ID,用半角逗号隔开,一次提交最多提供20个ID
108 * @throws WeiboException
110 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites/destroy_batch">favorites/destroy_batch</a>
111 * @since Weibo4J 1.2.1
113 public List
<Status
> destroyFavorites(String ids
)throws WeiboException
{
114 return Status
.constructStatuses(http
.post(getBaseURL()+"favorites/destroy_batch.json",
115 new PostParameter
[]{new PostParameter("ids",ids
)},true));
118 public List
<Status
> destroyFavorites(String
...ids
)throws WeiboException
{
119 StringBuilder sb
= new StringBuilder();
120 for(String id
: ids
) {
121 sb
.append(id
).append(',');
123 sb
.deleteCharAt(sb
.length() - 1);
124 return Status
.constructStatuses(http
.post(getBaseURL()+"favorites/destroy_batch.json",
125 new PostParameter
[]{new PostParameter("ids",sb
.toString())},true));
127 //----------------------------账号接口 ----------------------------------------
133 * @since Weibo4J 1.2.1
134 * @throws WeiboException when Weibo service or network is unavailable
135 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Account/verify_credentials">account/verify_credentials </a>
137 public User
verifyCredentials() throws WeiboException
{
138 /*return new User(get(getBaseURL() + "account/verify_credentials.xml"
140 return new User(get(getBaseURL() + "account/verify_credentials.json"
141 , true).asJSONObject());
146 * @param name Optional. Maximum of 20 characters.
147 * @param email Optional. Maximum of 40 characters. Must be a valid email address.
148 * @param url Optional. Maximum of 100 characters. Will be prepended with "http://" if not present.
149 * @param location Optional. Maximum of 30 characters. The contents are not normalized or geocoded in any way.
150 * @param description Optional. Maximum of 160 characters.
151 * @return the updated user
152 * @throws WeiboException when Weibo service or network is unavailable
153 * @since Weibo4J 1.2.1
154 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Account/update_profile">account/update_profile </a>
156 public User
updateProfile(String name
, String email
, String url
157 , String location
, String description
) throws WeiboException
{
158 List
<PostParameter
> profile
= new ArrayList
<PostParameter
>(5);
159 addParameterToList(profile
, "name", name
);
160 addParameterToList(profile
, "email", email
);
161 addParameterToList(profile
, "url", url
);
162 addParameterToList(profile
, "location", location
);
163 addParameterToList(profile
, "description", description
);
164 return new User(http
.post(getBaseURL() + "account/update_profile.json"
165 , profile
.toArray(new PostParameter
[profile
.size()]), true).asJSONObject());
172 * @throws WeiboException
173 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Account/update_profile_image">account/update_profile_image</a>
175 public User
updateProfileImage(File image
)throws WeiboException
{
176 return new User(http
.multPartURL("image",getBaseURL() + "account/update_profile_image.json",
177 new PostParameter
[]{new PostParameter("source",CONSUMER_KEY
)},image
, true).asJSONObject());
182 * @return the rate limit status
183 * @throws WeiboException when Weibo service or network is unavailable
184 * @since Weibo4J 1.2.1
185 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Account/rate_limit_status">account/rate_limit_status </a>
187 public RateLimitStatus
rateLimitStatus() throws WeiboException
{
188 return new RateLimitStatus(http
.get(getBaseURL() + "account/rate_limit_status.json" , true),this);
194 * @return a user's object
195 * @throws WeiboException when Weibo service or network is unavailable
197 public User
endSession() throws WeiboException
{
198 return new User(get(getBaseURL() + "account/end_session.json", true).asJSONObject());
200 //----------------------------Tags接口 ----------------------------------------
204 * @param user_id 用户id
207 * @throws WeiboException
208 * @since Weibo4J 1.2.1
209 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Tags">Tags </a>
211 public List
<Tag
> getTags(String userId
,Paging paging
) throws WeiboException
{
212 return Tag
.constructTags(get(getBaseURL()+"tags.json",
213 new PostParameter
[]{new PostParameter("user_id",userId
)},
220 * @throws WeiboException
221 * @throws JSONException
222 * @since Weibo4J 1.2.1
223 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Tags/create">Tags/create </a>
225 public List
<Tag
> createTags(String
...tags
)throws WeiboException
{
226 StringBuffer sb
= new StringBuffer();
227 for(String tag
:tags
){
228 sb
.append(tag
).append(",");
230 sb
.deleteCharAt(sb
.length()-1);
231 return createTags(sb
.toString());
236 * @param tags 要创建的一组标签,用半角逗号隔开。
238 * @throws WeiboException
239 * @throws JSONException
240 * @since Weibo4J 1.2.1
241 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Tags/create">Tags/create </a>
244 public List
<Tag
> createTags(String tags
)throws WeiboException
{
245 return Tag
.constructTags(http
.post(getBaseURL()+"tags/create.json",
246 new PostParameter
[]{new PostParameter("tags",tags
)},true));
251 * @return a list of tags
252 * @throws WeiboException
253 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Tags/suggestions">Tags/suggestions </a>
256 public List
<Tag
> getSuggestionsTags()throws WeiboException
{
257 return Tag
.constructTags(get(getBaseURL()+"tags/suggestions.json",true));
263 * @throws WeiboException
264 * @since Weibo4J 1.2.1
265 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Tags/destroy">Tags/destroy </a>
268 public boolean destoryTag(String tag_id
)throws WeiboException
{
270 return http
.post(getBaseURL()+"tags/destroy.json",
271 new PostParameter
[]{new PostParameter("tag_id",tag_id
)},true).asJSONObject().getInt("result") ==0;
272 } catch (JSONException e
) {
273 throw new WeiboException(e
);
280 * @throws WeiboException
281 * @since Weibo4J 1.2.1
282 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Tags/destroy_batch">Tags/destroy_batch </a>
285 public List
<Tag
> destory_batchTags(String ids
)throws WeiboException
{
286 return Tag
.constructTags(http
.post(getBaseURL()+"tags/destroy_batch.json",
287 new PostParameter
[]{new PostParameter("ids",ids
)},true));
292 //----------------------------黑名单接口 ---------------------------------------
297 * @return the blocked user
298 * @throws WeiboException when Weibo service or network is unavailable
299 * @since Weibo4J 1.2.1
300 * @see<a href="http://open.t.sina.com.cn/wiki/index.php/Blocks/create">Blocks/create</a>
302 public User
createBlock(String userid
) throws WeiboException
{
303 return new User(http
.post(getBaseURL() + "blocks/create.json",
304 new PostParameter
[]{new PostParameter("user_id", userid
)}, true).asJSONObject());
308 * @param screenName 用户昵称
309 * @return the blocked user
310 * @throws WeiboException when Weibo service or network is unavailable
311 * @since Weibo4J 1.2.1
312 * @see<a href="http://open.t.sina.com.cn/wiki/index.php/Blocks/create">Blocks/create</a>
314 public User
createBlockByScreenName(String screenName
) throws WeiboException
{
315 return new User(http
.post(getBaseURL() + "blocks/create.json",
316 new PostParameter
[]{new PostParameter("screen_name", screenName
)}, true).asJSONObject());
321 * Un-blocks the user specified in the ID parameter as the authenticating user. Returns the un-blocked user in the requested format when successful.
322 * @param id the ID or screen_name of the user to block
323 * @return the unblocked user
324 * @throws WeiboException when Weibo service or network is unavailable
325 * @since Weibo4J 1.2.1
327 public User
destroyBlock(String id
) throws WeiboException
{
328 return new User(http
.post(getBaseURL() + "blocks/destroy.json",
329 new PostParameter
[]{new PostParameter("id",id
)}, true).asJSONObject());
334 * Tests if a friendship exists between two users.
335 * @param id The ID or screen_name of the potentially blocked user.
336 * @return if the authenticating user is blocking a target user
337 * @throws WeiboException when Weibo service or network is unavailable
338 * @since Weibo4J 1.2.1
340 public boolean existsBlock(String id
) throws WeiboException
{
342 return -1 == get(getBaseURL() + "blocks/exists.json?user_id="+id
, true).
343 asString().indexOf("<error>You are not blocking this user.</error>");
344 }catch(WeiboException te
){
345 if(te
.getStatusCode() == 404){
353 * Returns a list of user objects that the authenticating user is blocking.
354 * @return a list of user objects that the authenticating user
355 * @throws WeiboException when Weibo service or network is unavailable
356 * @since Weibo4J 1.2.1
358 public List
<User
> getBlockingUsers() throws
360 /*return User.constructUsers(get(getBaseURL() +
361 "blocks/blocking.xml", true), this);*/
362 return User
.constructUsers(get(getBaseURL() +
363 "blocks/blocking.json", true));
367 * Returns a list of user objects that the authenticating user is blocking.
368 * @param page the number of page
369 * @return a list of user objects that the authenticating user
370 * @throws WeiboException when Weibo service or network is unavailable
371 * @since Weibo4J 1.2.1
373 public List
<User
> getBlockingUsers(int page
) throws
375 /*return User.constructUsers(get(getBaseURL() +
376 "blocks/blocking.xml?page=" + page, true), this);*/
377 return User
.constructUsers(get(getBaseURL() +
378 "blocks/blocking.json?page=" + page
, true));
382 * Returns an array of numeric user ids the authenticating user is blocking.
383 * @return Returns an array of numeric user ids the authenticating user is blocking.
384 * @throws WeiboException when Weibo service or network is unavailable
385 * @since Weibo4J 1.2.1
387 public IDs
getBlockingUsersIDs() throws WeiboException
{
388 // return new IDs(get(getBaseURL() + "blocks/blocking/ids.xml", true));
389 return new IDs(get(getBaseURL() + "blocks/blocking/ids.json", true),this);
391 //----------------------------Social Graph接口-----------------------------------
398 * @throws WeiboException
399 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">Friends/ids</a>
402 public IDs getFriendsIDSByUserId(String userid,int cursor,int count) throws WeiboException{
403 return new IDs(get(baseURL+"friends/ids.json",
404 new PostParameter[]{new PostParameter("user_id", userid),new PostParameter("cursor",cursor),new PostParameter("count",count)}, true),this);
407 public IDs
getFriendsIDSByUserId(String userid
,int cursor
) throws WeiboException
{
408 return new IDs(get(baseURL
+"friends/ids.json",
409 new PostParameter
[]{new PostParameter("user_id", userid
),new PostParameter("cursor",cursor
)}, true),this);
416 * @throws WeiboException
417 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">Friends/ids</a>
420 public IDs getFriendsIDSByScreenName(String userid,int cursor,int count) throws WeiboException{
421 return new IDs(get(baseURL+"friends/ids.json",
422 new PostParameter[]{new PostParameter("screen_name", screenName),new PostParameter("cursor",cursor),new PostParameter("count",count)}, true),this);
425 public IDs
getFriendsIDSByScreenName(String screenName
,int cursor
) throws WeiboException
{
426 return new IDs(get(baseURL
+"friends/ids.json",
427 new PostParameter
[]{new PostParameter("screen_name", screenName
),new PostParameter("cursor",cursor
)}, true),this);
434 * @throws WeiboException
435 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">Followers/ids</a>
438 public IDs getFollowersIDSByUserId(String userid,int cursor,int count) throws WeiboException{
439 return new IDs(get(baseURL+"followers/ids.json",
440 new PostParameter[]{new PostParameter("user_id", userid),new PostParameter("cursor",cursor),new PostParameter("count",count)}, true),this);
443 public IDs
getFollowersIDSByUserId(String userid
,int cursor
) throws WeiboException
{
444 return new IDs(get(baseURL
+"followers/ids.json",
445 new PostParameter
[]{new PostParameter("user_id", userid
),new PostParameter("cursor",cursor
)}, true),this);
452 * @throws WeiboException
453 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">Followers/ids</a>
456 public IDs getFollowersIDSByScreenName(String userid,int cursor,int count) throws WeiboException{
457 return new IDs(get(baseURL+"followers/ids.json",
458 new PostParameter[]{new PostParameter("screen_name", screenName),new PostParameter("cursor",cursor),new PostParameter("count",count)}, true),this);
461 public IDs
getFollowersIDSByScreenName(String screenName
,int cursor
) throws WeiboException
{
462 return new IDs(get(baseURL
+"followers/ids.json",
463 new PostParameter
[]{new PostParameter("screen_name", screenName
),new PostParameter("cursor",cursor
)}, true),this);
468 //----------------------------话题接口-------------------------------------------
472 * @throws WeiboException when Weibo service or network is unavailable
473 * @since Weibo4J 1.2.1
474 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Trends">Trends </a>
476 public List
<UserTrend
> getTrends(String userid
,Paging paging
) throws WeiboException
{
477 return UserTrend
.constructTrendList(get(baseURL
+ "trends.json",
478 new PostParameter
[]{new PostParameter("user_id", userid
)},paging
,true));
482 * @param trendName 话题名称
483 * @return list status
484 * @throws WeiboException
485 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Trends/statuses">Trends/statuses </a>
487 public List
<Status
> getTrendStatus(String trendName
,Paging paging
) throws WeiboException
{
488 return Status
.constructStatuses(get(baseURL
+ "trends/statuses.json",
489 new PostParameter
[]{new PostParameter("trend_name", trendName
)},
493 * @param treandName 话题名称
495 * @throws WeiboException
496 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Trends/follow">trends/follow</a>
498 public UserTrend
trendsFollow(String treandName
) throws WeiboException
{
499 return new UserTrend(http
.post(baseURL
+"trends/follow.json",new PostParameter
[]{new PostParameter("trend_name", treandName
)},true));
502 * @param trendId 话题id
504 * @throws WeiboException
505 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Trends/destroy">Trends/destroy</a>
507 public boolean trendsDestroy(String trendId
) throws WeiboException
{
508 JSONObject obj
= http
.delete(baseURL
+"trends/destroy.json?trend_id="+trendId
+"&source="+Weibo
.CONSUMER_KEY
, true).asJSONObject();
510 return obj
.getBoolean("result");
511 } catch (JSONException e
) {
512 throw new WeiboException("e");
517 * @param baseApp 是否基于当前应用来获取数据。1表示基于当前应用来获取数据。
519 * @throws WeiboException
520 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Trends/hourly">Trends/hourly</a>
522 public List
<Trends
> getTrendsHourly(Integer baseApp
)throws WeiboException
{
525 return Trends
.constructTrendsList(get(baseURL
+"trends/hourly.json","base_app",baseApp
.toString() ,true));
529 * @param baseApp 是否基于当前应用来获取数据。1表示基于当前应用来获取数据。
531 * @throws WeiboException
532 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Trends/daily">Trends/daily</a>
534 public List
<Trends
> getTrendsDaily(Integer baseApp
)throws WeiboException
{
537 return Trends
.constructTrendsList(get(baseURL
+"trends/daily.json","base_app",baseApp
.toString() ,true));
541 * @param baseApp 是否基于当前应用来获取数据。1表示基于当前应用来获取数据。
543 * @throws WeiboException
544 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Trends/weekly">Trends/weekly</a>
546 public List
<Trends
> getTrendsWeekly(Integer baseApp
)throws WeiboException
{
549 return Trends
.constructTrendsList(get(baseURL
+"trends/weekly.json","base_app",baseApp
.toString() ,true));
553 private String
toDateStr(Date date
){
557 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd");
558 return sdf
.format(date
);
562 //----------------------------关注接口-------------------------------------------
565 * 关注一个用户。关注成功则返回关注人的资料
566 * @param id 要关注的用户ID 或者微博昵称
567 * @return the befriended user
568 * @throws WeiboException when Weibo service or network is unavailable
569 * @since Weibo4J 1.2.1
570 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/create">friendships/create </a>
572 public User
createFriendship(String id
) throws WeiboException
{
573 return new User(http
.post(getBaseURL() + "friendships/create.json", new PostParameter
[]{new
574 PostParameter("id",id
)}, true).asJSONObject());
577 * 关注一个用户。关注成功则返回关注人的资料
579 * @return the befriended user
580 * @throws WeiboException when Weibo service or network is unavailable
581 * @since Weibo4J 1.2.1
582 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/create">friendships/create </a>
584 public User
createFriendshipByScreenName(String screenName
) throws WeiboException
{
585 return new User(http
.post(getBaseURL() + "friendships/create.json",
586 new PostParameter
[]{new PostParameter("screen_name", screenName
)}
587 , true).asJSONObject());
590 * 关注一个用户。关注成功则返回关注人的资料
592 * @return the befriended user
593 * @throws WeiboException when Weibo service or network is unavailable
594 * @since Weibo4J 1.2.1
595 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/create">friendships/create </a>
597 public User
createFriendshipByUserid(String userid
) throws WeiboException
{
598 return new User(http
.post(getBaseURL() + "friendships/create.json",
599 new PostParameter
[] {new PostParameter("user_id", userid
)}
600 , true).asJSONObject());
604 * @param id 要取消关注的用户ID 或者微博昵称
606 * @throws WeiboException when Weibo service or network is unavailable
607 * @since Weibo4J 1.2.1
608 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/destroy">friendships/destroy </a>
610 public User
destroyFriendship(String id
) throws WeiboException
{
611 return new User(http
.post(getBaseURL() + "friendships/destroy.json", "id",id
, true).asJSONObject());
615 * @param id 要取消关注的用户ID
617 * @throws WeiboException when Weibo service or network is unavailable
618 * @since Weibo4J 1.2.1
619 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/destroy">friendships/destroy </a>
621 public User
destroyFriendshipByUserid(String userid
) throws WeiboException
{
622 return new User(http
.post(getBaseURL() + "friendships/destroy.json", "user_id",""+userid
, true).asJSONObject());
626 * @param id 要取消关注的用户昵称
628 * @throws WeiboException when Weibo service or network is unavailable
629 * @since Weibo4J 1.2.1
630 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/destroy">friendships/destroy </a>
632 public User
destroyFriendshipByScreenName(String screenName
) throws WeiboException
{
633 return new User(http
.post(getBaseURL() + "friendships/destroy.json", "screen_name",screenName
, true).asJSONObject());
636 //----------------------------用户接口-------------------------------------------
638 * 按用户ID或昵称返回用户资料以及用户的最新发布的一条微博消息。
639 * @param id 用户ID或者昵称(string)
641 * @throws WeiboException when Weibo service or network is unavailable
642 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Users/show">users/show </a>
643 * @since Weibo4J 1.2.1
645 public User
showUser(String user_id
) throws WeiboException
{
646 return new User(get(getBaseURL() + "users/show.json",new PostParameter
[]{new PostParameter("id", user_id
)}
647 ,http
.isAuthenticationEnabled()).asJSONObject());
652 * 获取当前用户关注列表及每个关注用户的最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
653 * @return the list of friends
654 * @throws WeiboException when Weibo service or network is unavailable
655 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
656 * @since Weibo4J 1.2.1
658 public List
<User
> getFriendsStatuses() throws WeiboException
{
659 return User
.constructResult(get(getBaseURL() + "statuses/friends.json", true));
662 * 获取当前用户关注列表及每个关注用户的最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
663 * @return the list of friends
664 * @throws WeiboException when Weibo service or network is unavailable
665 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
666 * @since Weibo4J 1.2.1
668 public List
<User
>getFriendsStatuses(int cursor
) throws WeiboException
{
669 return User
.constructUser(get(getBaseURL()+"statuses/friends.json"
670 ,new PostParameter
[]{new PostParameter("cursor", cursor
)},true));
673 * 获取指定用户关注列表及每个关注用户的最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
674 * @param id 用户ID 或者昵称
676 * @return the list of friends
677 * @throws WeiboException when Weibo service or network is unavailable
678 * @since Weibo4J 1.2.1
679 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
681 public List
<User
> getFriendsStatuses(String id
, int cursor
) throws WeiboException
{
682 return User
.constructUsers(get(getBaseURL() + "statuses/friends.json",
683 new PostParameter
[]{new PostParameter("id", id
),new PostParameter("cursor", cursor
)},
687 * 获取当前用户关注列表及每个关注用户的最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
689 * @return the list of friends
690 * @throws WeiboException when Weibo service or network is unavailable
691 * @since Weibo4J 1.2.1
692 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
694 public List
<User
> getFriendsStatuses(String id
,int cursor
,int count
) throws WeiboException
{
695 /*return User.constructUsers(get(getBaseURL() + "statuses/friends.xml", null,
696 paging, true), this);*/
697 return User
.constructUsers(get(getBaseURL() + "statuses/friends.json",
698 new PostParameter
[]{new PostParameter("id",id
),new PostParameter("cursor",cursor
),new PostParameter("count",count
)} , true));
703 * 获取指定用户关注列表及每个关注用户的最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
704 * @param id id 用户ID 或者昵称
705 * @return the list of friends
706 * @throws WeiboException when Weibo service or network is unavailable
707 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
708 * @since Weibo4J 1.2.1
710 public List
<User
> getFriendsStatuses(String id
) throws WeiboException
{
711 /*return User.constructUsers(get(getBaseURL() + "statuses/friends/" + id + ".xml"
713 return User
.constructUsers(get(getBaseURL() + "statuses/friends.json"
714 ,new PostParameter
[]{new PostParameter("id", id
)}
719 * 获取当前用户粉丝列表及及每个粉丝用户最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
721 * @throws WeiboException when Weibo service or network is unavailable
722 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
723 * @since Weibo4J 1.2.1
725 public List
<User
> getFollowersStatuses() throws WeiboException
{
726 // return User.constructUsers(get(getBaseURL() + "statuses/followers.xml", true), this);
727 return User
.constructResult(get(getBaseURL() + "statuses/followers.json", true));
731 * 获取指定用户粉丝列表及及每个粉丝用户最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
732 * @param id 用户ID 或者昵称
733 * @param paging controls pagination
735 * @throws WeiboException when Weibo service or network is unavailable
736 * @since Weibo4J 1.2.1
737 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
739 public List
<User
> getFollowersStatuses(String id
, int cursor
) throws WeiboException
{
740 return User
.constructUser(get(getBaseURL() + "statuses/followers.json",
741 new PostParameter
[]{new PostParameter("id", id
),new PostParameter("cursor", cursor
)}, true));
745 * 获取当前用户粉丝列表及及每个粉丝用户最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
748 * @throws WeiboException when Weibo service or network is unavailable
749 * @since Weibo4J 1.2.1
750 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
752 public List
<User
> getFollowersStatuses(String id
,int cursor
,int count
) throws WeiboException
{
753 return User
.constructUsers(get(getBaseURL() + "statuses/followers.json",
754 new PostParameter
[]{new PostParameter("id", id
),new PostParameter("cursor", cursor
),new PostParameter("count",count
)}, true));
757 * 获取当前用户粉丝列表及及每个粉丝用户最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
760 * @throws WeiboException when Weibo service or network is unavailable
761 * @since Weibo4J 1.2.1
762 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
764 public List
<User
> getFollowersStatuses(int cursor
) throws WeiboException
{
765 return User
.constructUser(get(getBaseURL()+"statuses/followers.json",
766 new PostParameter
[]{new PostParameter("cursor", cursor
)},true));
770 * 获取指定用户前20 粉丝列表及及每个粉丝用户最新一条微博,返回结果按关注时间倒序排列,最新关注的用户排在最前面。
772 * @throws WeiboException when Weibo service or network is unavailable
773 * @since Weibo4J 1.2.1
774 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
776 public List
<User
> getFollowersStatuses(String id
) throws WeiboException
{
777 return User
.constructUsers(get(getBaseURL() + "statuses/followers.json",new PostParameter
[]{new PostParameter("id", id
)}, true));
782 * @param category 返回某一类别的推荐用户 具体目录参见文档
784 * @throws WeiboException
785 * @see<a href="http://open.t.sina.com.cn/wiki/index.php/Users/hot">users/hot</a>
786 * @since Weibo4J 1.2.1
788 public List
<User
> getHotUsers(String category
) throws WeiboException
{
789 return User
.constructUsers(get(getBaseURL()+"users/hot.json","category", category
, true));
793 * 更新当前登录用户所关注的某个好友的备注信息。
794 * @param userid 需要修改备注信息的用户ID。
797 * @throws WeiboException
798 * @see<a href="http://open.t.sina.com.cn/wiki/index.php/User/friends/update_remark">friends/update_remark</a>
800 public User
updateRemark(String userid
,String remark
) throws WeiboException
{
801 if(!URLEncodeUtils
.isURLEncoded(remark
))
802 remark
=URLEncodeUtils
.encodeURL(remark
);
803 return new User(http
.post(getBaseURL()+"user/friends/update_remark.json",
804 new PostParameter
[]{new PostParameter("user_id", userid
),
805 new PostParameter("remark", remark
)},
806 true).asJSONObject());
809 * 更新当前登录用户所关注的某个好友的备注信息。
810 * @param userid 需要修改备注信息的用户ID。
813 * @throws WeiboException
814 * @see<a href="http://open.t.sina.com.cn/wiki/index.php/User/friends/update_remark">friends/update_remark</a>
816 public User
updateRemark(Long userid
,String remark
) throws WeiboException
{
817 return updateRemark(Long
.toString(userid
), remark
);
823 * @throws WeiboException
824 * * @see<a href="http://open.t.sina.com.cn/wiki/index.php/Users/suggestions">friends/update_remark</a>
826 public List
<User
> getSuggestionUsers() throws WeiboException
{
827 return User
.constructUsers(get(getBaseURL()+"users/suggestions.json","with_reason", "0", true));
831 //-----------------------获取下行数据集(timeline)接口-----------------------------
833 * 返回最新的20条公共微博。返回结果非完全实时,最长会缓存60秒
834 * @return list of statuses of the Public Timeline
835 * @throws WeiboException when Weibo service or network is unavailable
836 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/public_timeline">statuses/public_timeline </a>
838 public List
<Status
> getPublicTimeline() throws
840 return Status
.constructStatuses(get(getBaseURL() +
841 "statuses/public_timeline.json", true));
844 * @param count 每次返回的记录数
845 * @param baseApp 是否仅获取当前应用发布的信息。0为所有,1为仅本应用。
847 * @throws WeiboException
849 public List
<Status
> getPublicTimeline(int count
,int baseApp
) throws WeiboException
{
850 return Status
.constructStatuses(get(getBaseURL() +
851 "statuses/public_timeline.json",
853 new PostParameter("count", count
),
854 new PostParameter("base_app", baseApp
)
859 * 获取当前登录用户及其所关注用户的最新20条微博消息。<br/>
860 * 和用户登录 http://t.sina.com.cn 后在“我的首页”中看到的内容相同。
861 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
863 * @return list of the Friends Timeline
864 * @throws WeiboException when Weibo service or network is unavailable
865 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
867 public List
<Status
> getFriendsTimeline() throws
869 return Status
.constructStatuses(get(getBaseURL() + "statuses/friends_timeline.json", true));
873 *获取当前登录用户及其所关注用户的最新微博消息。<br/>
874 * 和用户登录 http://t.sina.com.cn 后在“我的首页”中看到的内容相同。
875 * @param paging 相关分页参数
876 * @return list of the Friends Timeline
877 * @throws WeiboException when Weibo service or network is unavailable
878 * @since Weibo4J 1.2.1
879 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
881 public List
<Status
> getFriendsTimeline(Paging paging
) throws
883 return Status
.constructStatuses(get(getBaseURL() + "statuses/friends_timeline.json",null, paging
, true));
887 *获取当前登录用户及其所关注用户的最新微博消息。<br/>
888 * 和用户登录 http://t.sina.com.cn 后在“我的首页”中看到的内容相同。
889 * @return list of the home Timeline
890 * @throws WeiboException when Weibo service or network is unavailable
891 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
892 * @since Weibo4J 1.2.1
894 public List
<Status
> getHomeTimeline() throws
896 return Status
.constructStatuses(get(getBaseURL() + "statuses/home_timeline.json", true));
901 *获取当前登录用户及其所关注用户的最新微博消息。<br/>
902 * 和用户登录 http://t.sina.com.cn 后在“我的首页”中看到的内容相同。
903 * @param paging controls pagination
904 * @return list of the home Timeline
905 * @throws WeiboException when Weibo service or network is unavailable
906 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
907 * @since Weibo4J 1.2.1
909 public List
<Status
> getHomeTimeline(Paging paging
) throws
911 return Status
.constructStatuses(get(getBaseURL() + "statuses/home_timeline.json", null, paging
, true));
915 * @param id 根据用户ID(int64)或者微博昵称(string)返回指定用户的最新微博消息列表。
917 * @return list of the user Timeline
918 * @throws WeiboException when Weibo service or network is unavailable
919 * @since Weibo4J 1.2.1
920 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
922 public List
<Status
> getUserTimeline(String id
, Paging paging
)
923 throws WeiboException
{
924 // return Status.constructStatuses(get(getBaseURL() + "statuses/user_timeline/" + id + ".xml",
925 // null, paging, http.isAuthenticationEnabled()), this);
926 return Status
.constructStatuses(get(getBaseURL() + "statuses/user_timeline.json",
927 new PostParameter
[]{new PostParameter("id", id
)}, paging
, http
.isAuthenticationEnabled()));
929 public List
<Status
> getUserTimeline(String id
,Integer baseAPP
,Integer feature
, Paging paging
)
930 throws WeiboException
{
931 Map
<String
,String
> maps
= new HashMap
<String
, String
>();
936 maps
.put("base_app", baseAPP
.toString());
939 maps
.put("feature", feature
.toString());
941 return Status
.constructStatuses(get(getBaseURL() + "statuses/user_timeline.json",
942 generateParameterArray(maps
), paging
, http
.isAuthenticationEnabled()));
946 * @param id 根据用户ID(int64)或者微博昵称(string)返回指定用户的最新微博消息列表。
947 * @return the 20 most recent statuses posted in the last 24 hours from the user
948 * @throws WeiboException when Weibo service or network is unavailable
949 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
951 public List
<Status
> getUserTimeline(String id
) throws WeiboException
{
952 return Status
.constructStatuses(get(getBaseURL() + "statuses/user_timeline.json",
953 new PostParameter
[]{new PostParameter("id", id
)},
954 http
.isAuthenticationEnabled()));
958 * @return the 20 most recent statuses posted in the last 24 hours from the user
959 * @throws WeiboException when Weibo service or network is unavailable
960 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
962 public List
<Status
> getUserTimeline() throws
964 return Status
.constructStatuses(get(getBaseURL() + "statuses/user_timeline.json"
970 * @param paging controls pagination
971 * @return the 20 most recent statuses posted in the last 24 hours from the user
972 * @throws WeiboException when Weibo service or network is unavailable
973 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
974 * @since Weibo4J 1.2.1
976 public List
<Status
> getUserTimeline(Paging paging
) throws
978 return Status
.constructStatuses(get(getBaseURL() + "statuses/user_timeline.json"
979 , null, paging
, true));
983 * @param paging controls pagination
984 * @param base_app 是否基于当前应用来获取数据。1为限制本应用微博,0为不做限制。
985 * @param feature 微博类型,0全部,1原创,2图片,3视频,4音乐. 返回指定类型的微博信息内容。
986 * @return the 20 most recent statuses posted in the last 24 hours from the user
987 * @throws WeiboException when Weibo service or network is unavailable
988 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
989 * @since Weibo4J 1.2.1
991 public List
<Status
> getUserTimeline(Integer baseAPP
,Integer feature
,Paging paging
) throws
993 return getUserTimeline(null,baseAPP
,feature
,paging
);
996 * 返回最新20条提到登录用户的微博消息(即包含@username的微博消息)
997 * @return the 20 most recent replies
998 * @throws WeiboException when Weibo service or network is unavailable
999 * @since Weibo4J 1.2.1
1000 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/mentions">Statuses/mentions </a>
1002 public List
<Status
> getMentions() throws WeiboException
{
1003 return Status
.constructStatuses(get(getBaseURL() + "statuses/mentions.json",
1008 * 返回最新提到登录用户的微博消息(即包含@username的微博消息)
1009 * @param paging 分页数据
1010 * @return the 20 most recent replies
1011 * @throws WeiboException when Weibo service or network is unavailable
1012 * @since Weibo4J 1.2.1
1013 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/mentions">Statuses/mentions </a>
1015 public List
<Status
> getMentions(Paging paging
) throws WeiboException
{
1016 return Status
.constructStatuses(get(getBaseURL() + "statuses/mentions.json",
1017 null, paging
, true));
1018 /*return Status.constructStatuses(get(getBaseURL() + "statuses/mentions.xml",
1019 null, paging, true), this);*/
1024 * @return a list of comments objects
1025 * @throws WeiboException when Weibo service or network is unavailable
1026 * @since Weibo4J 1.2.1
1027 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comments_timeline">Statuses/comments_timeline</a>
1029 public List
<Comment
> getCommentsTimeline() throws WeiboException
{
1030 return Comment
.constructComments(get(getBaseURL() + "statuses/comments_timeline.json", true));
1034 * @param paging 分页数据
1035 * @return a list of comments objects
1036 * @throws WeiboException when Weibo service or network is unavailable
1037 * @since Weibo4J 1.2.1
1038 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comments_timeline">Statuses/comments_timeline</a>
1040 public List
<Comment
> getCommentsTimeline(Paging paging
) throws WeiboException
{
1041 return Comment
.constructComments(get(getBaseURL() + "statuses/comments_timeline.json",null,paging
, true));
1046 * @return a list of comments objects
1047 * @throws WeiboException when Weibo service or network is unavailable
1048 * @since Weibo4J 1.2.1
1049 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comments_by_me">Statuses/comments_by_me</a>
1051 public List
<Comment
> getCommentsByMe() throws WeiboException
{
1052 return Comment
.constructComments(get(getBaseURL() + "statuses/comments_by_me.json", true));
1057 * @return a list of comments objects
1058 * @throws WeiboException when Weibo service or network is unavailable
1059 * @since Weibo4J 1.2.1
1060 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comments_by_me">Statuses/comments_by_me</a>
1062 public List
<Comment
> getCommentsByMe(Paging paging
) throws WeiboException
{
1063 return Comment
.constructComments(get(getBaseURL() + "statuses/comments_by_me.json",null,paging
, true));
1067 * 返回最新20条当前登录用户收到的评论
1068 * @return a list of comments objects
1069 * @throws WeiboException when Weibo service or network is unavailable
1070 * @since Weibo4J 1.2.1
1071 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comments_to_me">Statuses/comments_to_me</a>
1073 public List
<Comment
> getCommentsToMe() throws WeiboException
{
1074 return Comment
.constructComments(get(getBaseURL() + "statuses/comments_to_me.json", true));
1079 * @return a list of comments objects
1080 * @throws WeiboException when Weibo service or network is unavailable
1081 * @since Weibo4J 1.2.1
1082 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comments_to_me">Statuses/comments_to_me</a>
1084 public List
<Comment
> getCommentsToMe(Paging paging
) throws WeiboException
{
1085 return Comment
.constructComments(get(getBaseURL() + "statuses/comments_to_me.json",null,paging
, true));
1092 * @param id specifies the id of user
1094 * @throws WeiboException when Weibo service or network is unavailable
1095 * @since Weibo4J 1.2.1
1096 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/repost_by_me">Statuses/repost_by_me</a>
1098 public List
<Status
> getrepostbyme(String id
)throws WeiboException
{
1099 return Status
.constructStatuses(get(getBaseURL()+"statuses/repost_by_me.json","id",id
,true));
1103 * @param id specifies the id of user
1105 * @throws WeiboException when Weibo service or network is unavailable
1106 * @since Weibo4J 1.2.1
1107 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/repost_by_me">Statuses/repost_by_me</a>
1109 public List
<Status
> getrepostbyme(String id
,Paging paging
)throws WeiboException
{
1110 return Status
.constructStatuses(get(getBaseURL()+"statuses/repost_by_me.json",
1111 new PostParameter
[]{new PostParameter("id", id
)},
1115 * 返回一条原创微博的最新20条转发微博信息本接口无法对非原创微博进行查询。
1116 * @param id specifies the id of original status.
1117 * @return a list of statuses object
1118 * @throws WeiboException
1119 * @since Weibo4J 1.2.1
1120 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/repost_timeline">Statuses/repost_timeline</a>
1122 public List
<Status
>getreposttimeline(String id
)throws WeiboException
{
1123 return Status
.constructStatuses(get(getBaseURL()+"statuses/repost_timeline.json",
1127 * 返回一条原创微博的最新n条转发微博信息,本接口无法对非原创微博进行查询。
1128 * @param id specifies the id of original status.
1129 * @return a list of statuses object
1130 * @throws WeiboException
1131 * @since Weibo4J 1.2.1
1132 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/repost_timeline">Statuses/repost_timeline</a>
1134 public List
<Status
>getreposttimeline(String id
,Paging paging
)throws WeiboException
{
1135 return Status
.constructStatuses(get(getBaseURL()+"statuses/repost_timeline.json"
1136 ,new PostParameter
[]{new PostParameter("id", id
)},
1140 * 根据微博消息ID返回某条微博消息的20条评论列表
1141 * @param id specifies the ID of status
1142 * @return a list of comments objects
1143 * @throws WeiboException when Weibo service or network is unavailable
1144 * @since Weibo4J 1.2.1
1145 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comments">Statuses/comments</a>
1147 public List
<Comment
> getComments(String id
) throws WeiboException
{
1148 return Comment
.constructComments(get(getBaseURL() + "statuses/comments.json","id",id
, true));
1151 * 根据微博消息ID返回某条微博消息的n评论列表
1152 * @param id specifies the ID of status
1153 * @return a list of comments objects
1154 * @throws WeiboException when Weibo service or network is unavailable
1155 * @since Weibo4J 1.2.1
1156 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comments">Statuses/comments</a>
1158 public List
<Comment
> getComments(String id
,Paging paging
) throws WeiboException
{
1159 return Comment
.constructComments(get(getBaseURL() + "statuses/comments.json",
1160 new PostParameter
[]{new PostParameter("id", id
)},paging
,
1164 * 批量获取n条微博消息的评论数和转发数。要获取评论数和转发数的微博消息ID列表,用逗号隔开
1165 * 一次请求最多可以获取100条微博消息的评论数和转发数
1166 * @param ids ids a string, separated by commas
1167 * @return a list of counts objects
1168 * @throws WeiboException when Weibo service or network is unavailable
1169 * @since Weibo4J 1.2.1
1170 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/counts">Statuses/counts</a>
1172 public List
<Count
> getCounts(String ids
) throws WeiboException
{
1173 return Count
.constructCounts(get(getBaseURL() + "statuses/counts.json","ids",ids
, true));
1179 * @return count objects
1180 * @throws WeiboException when Weibo service or network is unavailable
1181 * @throws JSONException
1182 * @since Weibo4J 1.2.1
1183 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/unread">Statuses/unread</a>
1185 public Count
getUnread() throws WeiboException
{
1186 return new Count(get(getBaseURL() + "statuses/unread.json", true));
1190 * @param withNewStatus 1表示结果中包含new_status字段,0表示结果不包含new_status字段。new_status字段表示是否有新微博消息,1表示有,0表示没有
1191 * @param sinceId 参数值为微博id。该参数需配合with_new_status参数使用,返回since_id之后,是否有新微博消息产生
1193 * @throws WeiboException
1194 * @throws JSONException
1195 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/unread">Statuses/unread</a>
1197 public Count
getUnread(Integer withNewStatus
,Long sinceId
) throws WeiboException
, JSONException
{
1198 Map
<String
, String
> maps
= new HashMap
<String
, String
>();
1199 if(withNewStatus
!=null)
1200 maps
.put("with_new_status",Integer
.toString( withNewStatus
));
1202 maps
.put("since_id",Long
.toString( sinceId
));
1203 return new Count(get(getBaseURL() + "statuses/unread.json", generateParameterArray(maps
),true).asJSONObject());
1207 *将当前登录用户的某种新消息的未读数为0
1208 * @param type 1. 评论数,2.@ me数,3. 私信数,4. 关注数
1210 * @throws WeiboException
1211 * @since Weibo4J 1.2.1
1212 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/reset_count">statuses/reset_count</a>
1214 public Boolean
resetCount(int type
)throws WeiboException
{
1216 JSONObject json
= null;
1218 json
=http
.post(getBaseURL()+"statuses/reset_count.json",
1219 new PostParameter
[]{new PostParameter("type",type
)},true).asJSONObject();
1220 res
=json
.getBoolean("result");
1221 } catch (JSONException je
) {
1222 throw new WeiboException(je
.getMessage() + ":" + json
,
1229 * 返回新浪微博官方所有表情、魔法表情的相关信息。包括短语、表情类型、表情分类,是否热门等。
1230 * @param type 表情类别。"face":普通表情,"ani":魔法表情,"cartoon":动漫表情
1231 * @param language 语言类别,"cnname"简体,"twname"繁体
1233 * @throws WeiboException
1234 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Emotions">Emotions</a>
1236 public List
<Emotion
> getEmotions(String type
,String language
)throws WeiboException
{
1241 Map
<String
, String
> maps
= new HashMap
<String
, String
>();
1242 maps
.put("type", type
);
1243 maps
.put("language", language
);
1244 return Emotion
.constructEmotions(get(getBaseURL()+"emotions.json",generateParameterArray(maps
),true));
1249 * @throws WeiboException
1250 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Emotions">Emotions</a>
1252 public List
<Emotion
> getEmotions()throws WeiboException
{
1253 return getEmotions(null,null);
1255 //--------------微博访问接口----------
1258 * 根据ID获取单条微博消息,以及该微博消息的作者信息。
1259 * @param id 要获取的微博消息ID
1261 * @throws WeiboException when Weibo service or network is unavailable
1262 * @since Weibo4J 1.2.1
1263 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/show">statuses/show </a>
1265 public Status
showStatus(String id
) throws WeiboException
{
1266 return new Status(get(getBaseURL() + "statuses/show/" + id
+ ".json", true));
1269 * 根据ID获取单条微博消息,以及该微博消息的作者信息。
1270 * @param id 要获取的微博消息ID
1272 * @throws WeiboException when Weibo service or network is unavailable
1273 * @since Weibo4J 1.2.1
1274 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/show">statuses/show </a>
1276 public Status
showStatus(long id
) throws WeiboException
{
1277 return showStatus(Long
.toString(id
));
1282 * @param status 要发布的微博消息文本内容
1283 * @return the latest status
1284 * @throws WeiboException when Weibo service or network is unavailable
1285 * @since Weibo4J 1.2.1
1286 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/update">statuses/update </a>
1288 public Status
updateStatus(String status
) throws WeiboException
{
1290 return new Status(http
.post(getBaseURL() + "statuses/update.json",
1291 new PostParameter
[]{new PostParameter("status", status
)}, true));
1296 * @param status 要发布的微博消息文本内容
1297 * @param latitude 纬度。有效范围:-90.0到+90.0,+表示北纬。
1298 * @param longitude 经度。有效范围:-180.0到+180.0,+表示东经。
1299 * @return the latest status
1300 * @throws WeiboException when Weibo service or network is unavailable
1301 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/update">statuses/update </a>
1302 * @since Weibo4J 1.2.1
1304 public Status
updateStatus(String status
, double latitude
, double longitude
) throws WeiboException
{
1305 return new Status(http
.post(getBaseURL() + "statuses/update.json",
1306 new PostParameter
[]{new PostParameter("status", status
),
1307 new PostParameter("lat", latitude
),
1308 new PostParameter("long", longitude
)}, true));
1313 * @param status 要发布的微博消息文本内容
1314 * @param inReplyToStatusId 要转发的微博消息ID
1315 * @return the latest status
1316 * @throws WeiboException when Weibo service or network is unavailable
1317 * @since Weibo4J 1.2.1
1318 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/update">statuses/update </a>
1320 public Status
updateStatus(String status
, long inReplyToStatusId
) throws WeiboException
{
1321 return new Status(http
.post(getBaseURL() + "statuses/update.json",
1322 new PostParameter
[]{new PostParameter("status", status
), new PostParameter("in_reply_to_status_id", String
.valueOf(inReplyToStatusId
)), new PostParameter("source", source
)}, true));
1327 * @param status 要发布的微博消息文本内容
1328 * @param inReplyToStatusId 要转发的微博消息ID
1329 * @param latitude 纬度。有效范围:-90.0到+90.0,+表示北纬。
1330 * @param longitude 经度。有效范围:-180.0到+180.0,+表示东经。
1331 * @return the latest status
1332 * @throws WeiboException when Weibo service or network is unavailable
1333 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/update">statuses/update </a>
1334 * @since Weibo4J 1.2.1
1336 public Status
updateStatus(String status
, long inReplyToStatusId
1337 , double latitude
, double longitude
) throws WeiboException
{
1338 return new Status(http
.post(getBaseURL() + "statuses/update.json",
1339 new PostParameter
[]{new PostParameter("status", status
),
1340 new PostParameter("lat", latitude
),
1341 new PostParameter("long", longitude
),
1342 new PostParameter("in_reply_to_status_id",
1343 String
.valueOf(inReplyToStatusId
)),
1344 new PostParameter("source", source
)}, true));
1348 * 发表图片微博消息。目前上传图片大小限制为<5M。
1349 * @param status 要发布的微博消息文本内容
1350 * @param item 要上传的图片
1351 * @return the latest status
1352 * @throws WeiboException when Weibo service or network is unavailable
1353 * @since Weibo4J 1.2.1
1354 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/upload">statuses/upload </a>
1356 public Status
uploadStatus(String status
,ImageItem item
) throws WeiboException
{
1357 if(!URLEncodeUtils
.isURLEncoded(status
))
1358 status
=URLEncodeUtils
.encodeURL(status
);
1359 return new Status(http
.multPartURL(getBaseURL() + "statuses/upload.json",
1360 new PostParameter
[]{new PostParameter("status", status
), new PostParameter("source", source
)},item
, true));
1363 * 发表图片微博消息。目前上传图片大小限制为<5M。
1364 * @param status 要发布的微博消息文本内容
1365 * @param item 要上传的图片
1366 * @param latitude 纬度。有效范围:-90.0到+90.0,+表示北纬。
1367 * @param longitude 经度。有效范围:-180.0到+180.0,+表示东经。
1369 * @throws WeiboException
1371 public Status
uploadStatus(String status
,ImageItem item
, double latitude
, double longitude
) throws WeiboException
{
1372 if(!URLEncodeUtils
.isURLEncoded(status
))
1373 status
=URLEncodeUtils
.encodeURL(status
);
1374 return new Status(http
.multPartURL(getBaseURL() + "statuses/upload.json",
1375 new PostParameter
[]{new PostParameter("status", status
),
1376 new PostParameter("source", source
),
1377 new PostParameter("lat", latitude
),
1378 new PostParameter("long", longitude
),
1383 * 发表图片微博消息。目前上传图片大小限制为<5M。
1384 * @param status 要发布的微博消息文本内容
1385 * @param file 要上传的图片
1387 * @throws WeiboException when Weibo service or network is unavailable
1388 * @since Weibo4J 1.2.1
1389 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/upload">statuses/upload </a>
1391 public Status
uploadStatus(String status
,File file
) throws WeiboException
{
1392 if(!URLEncodeUtils
.isURLEncoded(status
))
1393 status
=URLEncodeUtils
.encodeURL(status
);
1394 return new Status(http
.multPartURL("pic",getBaseURL() + "statuses/upload.json",
1395 new PostParameter
[]{new PostParameter("status", status
), new PostParameter("source", source
)},file
, true));
1398 * 发表图片微博消息。目前上传图片大小限制为<5M。
1399 * @param status 要发布的微博消息文本内容
1400 * @param file 要上传的图片
1401 * @param latitude 纬度。有效范围:-90.0到+90.0,+表示北纬。
1402 * @param longitude 经度。有效范围:-180.0到+180.0,+表示东经。
1404 * @throws WeiboException when Weibo service or network is unavailable
1405 * @since Weibo4J 1.2.1
1406 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/upload">statuses/upload </a>
1408 public Status
uploadStatus(String status
,File file
, double latitude
, double longitude
) throws WeiboException
{
1409 if(!URLEncodeUtils
.isURLEncoded(status
))
1410 status
=URLEncodeUtils
.encodeURL(status
);
1411 return new Status(http
.multPartURL("pic",getBaseURL() + "statuses/upload.json",
1412 new PostParameter
[]{new PostParameter("status", status
),
1413 new PostParameter("source", source
),
1414 new PostParameter("lat", latitude
),
1415 new PostParameter("long", longitude
)},
1421 * Destroys the status specified by the required ID parameter. The authenticating user must be the author of the specified status.
1422 * <br>This method calls http://api.t.sina.com.cn/statuses/destroy/id.format
1424 * @param statusId The ID of the status to destroy.
1425 * @return the deleted status
1426 * @throws WeiboException when Weibo service or network is unavailable
1427 * @since Weibo4J 1.2.1
1428 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/destroy">statuses/destroy </a>
1430 public Status
destroyStatus(long statusId
) throws WeiboException
{
1431 return destroyStatus(Long
.toString(statusId
));
1433 public Status
destroyStatus(String statusId
) throws WeiboException
{
1434 return new Status(http
.post(getBaseURL() + "statuses/destroy/" + statusId
+ ".json",
1435 new PostParameter
[0], true));
1440 * @param sid 要转发的微博ID
1441 * @param status 添加的转发文本。必须做URLEncode,信息内容不超过140个汉字。如不填则默认为“转发微博”。
1442 * @return a single status
1443 * @throws WeiboException when Weibo service or network is unavailable
1444 * @since Weibo4J 1.2.1
1446 public Status
repost(String sid
,String status
) throws WeiboException
{
1447 return repost(sid
, status
,0);
1451 * @param sid 要转发的微博ID
1452 * @param status 添加的转发文本。必须做URLEncode,信息内容不超过140个汉字。如不填则默认为“转发微博”。
1453 * @param isComment 是否在转发的同时发表评论。1表示发表评论,0表示不发表.
1454 * @return a single status
1455 * @throws WeiboException when Weibo service or network is unavailable
1456 * @since Weibo4J 1.2.1
1458 public Status
repost(String sid
,String status
,int isComment
) throws WeiboException
{
1459 return new Status(http
.post(getBaseURL() + "statuses/repost.json",
1460 new PostParameter
[]{new PostParameter("id", sid
),
1461 new PostParameter("status", status
),
1462 new PostParameter("is_comment", isComment
)}, true));
1467 * @param 评论内容。必须做URLEncode,信息内容不超过140个汉字。
1468 * @param id 要评论的微博消息ID
1469 * @param cid 要回复的评论ID,可以为null.如果id及cid不存在,将返回400错误
1470 * </br>如果提供了正确的cid参数,则该接口的表现为回复指定的评论。<br/>此时id参数将被忽略。<br/>即使cid参数代表的评论不属于id参数代表的微博消息,通过该接口发表的评论信息直接回复cid代表的评论。
1471 * @return the comment object
1472 * @throws WeiboException
1473 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comment">Statuses/comment</a>
1475 public Comment
updateComment(String comment
, String id
, String cid
) throws WeiboException
{
1476 PostParameter
[] params
= null;
1478 params
= new PostParameter
[] {
1479 new PostParameter("comment", comment
),
1480 new PostParameter("id", id
)
1483 params
= new PostParameter
[] {
1484 new PostParameter("comment", comment
),
1485 new PostParameter("cid", cid
),
1486 new PostParameter("id", id
)
1488 return new Comment(http
.post(getBaseURL() + "statuses/comment.json", params
, true));
1491 * 删除评论。注意:只能删除登录用户自己发布的评论,不可以删除其他人的评论。
1492 * @param statusId 欲删除的评论ID
1493 * @return the deleted status
1494 * @throws WeiboException when Weibo service or network is unavailable
1495 * @since Weibo4J 1.2.1
1496 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comment_destroy">statuses/comment_destroy </a>
1498 public Comment
destroyComment(long commentId
) throws WeiboException
{
1499 return new Comment(http
.delete(getBaseURL()
1500 + "statuses/comment_destroy/" + commentId
+ ".json?source="
1501 + CONSUMER_KEY
, true));
1505 * 批量删除评论。注意:只能删除登录用户自己发布的评论,不可以删除其他人的评论。
1507 * @param ids 欲删除的一组评论ID,用半角逗号隔开,最多20个
1509 * @throws WeiboException
1510 * @since Weibo4J 1.2.1
1511 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/comment/destroy_batch">statuses/comment/destroy batch</a>
1513 public List
<Comment
> destroyComments(String ids
)throws WeiboException
{
1514 return Comment
.constructComments(http
.post(getBaseURL()+"statuses/comment/destroy_batch.json",
1515 new PostParameter
[]{new PostParameter("ids",ids
)},true));
1517 public List
<Comment
> destroyComments(String
[] ids
)throws WeiboException
{
1518 StringBuilder sb
= new StringBuilder();
1519 for(String id
: ids
) {
1520 sb
.append(id
).append(',');
1522 sb
.deleteCharAt(sb
.length() - 1);
1523 return Comment
.constructComments(http
.post(getBaseURL()+"statuses/comment/destroy_batch.json",
1524 new PostParameter
[]{new PostParameter("ids",sb
.toString())},true));
1529 * @param sid 要回复的评论ID。
1530 * @param cid 要评论的微博消息ID
1531 * @param comment 要回复的评论内容。必须做URLEncode,信息内容不超过140个汉字
1532 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/reply">Statuses/reply</a>
1533 * @throws WeiboException when Weibo service or network is unavailable
1534 * @since Weibo4J 1.2.1
1536 public Comment
reply(String sid
, String cid
, String comment
)
1537 throws WeiboException
{
1538 return new Comment(http
.post(getBaseURL() + "statuses/reply.json",
1539 new PostParameter
[] { new PostParameter("id", sid
),
1540 new PostParameter("cid", cid
),
1541 new PostParameter("comment", comment
) }, true));
1544 //--------------auth method----------
1547 * @param consumerKey OAuth consumer key
1548 * @param consumerSecret OAuth consumer secret
1549 * @since Weibo4J 1.2.1
1551 public synchronized void setOAuthConsumer(String consumerKey
, String consumerSecret
){
1552 this.http
.setOAuthConsumer(consumerKey
, consumerSecret
);
1557 * @return generated request token.
1558 * @throws WeiboException when Weibo service or network is unavailable
1559 * @since Weibo4J 1.2.1
1560 * @see <a href="http://oauth.net/core/1.0/#auth_step1">OAuth Core 1.0 - 6.1. Obtaining an Unauthorized Request Token</a>
1562 public RequestToken
getOAuthRequestToken() throws WeiboException
{
1563 return http
.getOAuthRequestToken();
1566 public RequestToken
getOAuthRequestToken(String callback_url
) throws WeiboException
{
1567 return http
.getOauthRequestToken(callback_url
);
1571 * 通过request token获取access token
1572 * @param requestToken the request token
1573 * @return access token associsted with the supplied request token.
1574 * @throws WeiboException when Weibo service or network is unavailable, or the user has not authorized
1575 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Oauth/access_token">Oauth/access token </a>
1576 * @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2. Obtaining User Authorization</a>
1577 * @since Weibo4J 1.2.1
1579 public synchronized AccessToken
getOAuthAccessToken(RequestToken requestToken
) throws WeiboException
{
1580 return http
.getOAuthAccessToken(requestToken
);
1584 * Retrieves an access token assosiated with the supplied request token and sets userId.
1585 * @param requestToken the request token
1587 * @return access token associsted with the supplied request token.
1588 * @throws WeiboException when Weibo service or network is unavailable, or the user has not authorized
1589 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Oauth/access_token">Oauth/access token </a>
1590 * @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2. Obtaining User Authorization</a>
1591 * @since Weibo4J 1.2.1
1593 public synchronized AccessToken
getOAuthAccessToken(RequestToken requestToken
, String pin
) throws WeiboException
{
1594 AccessToken accessToken
= http
.getOAuthAccessToken(requestToken
, pin
);
1595 // setUserId(accessToken.getScreenName());
1600 * Retrieves an access token assosiated with the supplied request token and sets userId.
1601 * @param token request token
1602 * @param tokenSecret request token secret
1603 * @return access token associsted with the supplied request token.
1604 * @throws WeiboException when Weibo service or network is unavailable, or the user has not authorized
1605 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Oauth/access_token">Oauth/access token </a>
1606 * @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2. Obtaining User Authorization</a>
1607 * @since Weibo4J 1.2.1
1609 public synchronized AccessToken
getOAuthAccessToken(String token
, String tokenSecret
) throws WeiboException
{
1610 AccessToken accessToken
= http
.getOAuthAccessToken(token
, tokenSecret
);
1611 // setUserId(accessToken.getScreenName());
1616 * Retrieves an access token assosiated with the supplied request token.
1617 * @param token request token
1618 * @param tokenSecret request token secret
1619 * @param oauth_verifier oauth_verifier or pin
1620 * @return access token associsted with the supplied request token.
1621 * @throws WeiboException when Weibo service or network is unavailable, or the user has not authorized
1622 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Oauth/access_token">Oauth/access token </a>
1623 * @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2. Obtaining User Authorization</a>
1624 * @since Weibo4J 1.2.1
1626 public synchronized AccessToken
getOAuthAccessToken(String token
1627 , String tokenSecret
, String oauth_verifier
) throws WeiboException
{
1628 return http
.getOAuthAccessToken(token
, tokenSecret
, oauth_verifier
);
1631 public synchronized AccessToken
getXAuthAccessToken(String userId
,String passWord
,String mode
) throws WeiboException
{
1632 return http
.getXAuthAccessToken(userId
, passWord
, mode
);
1634 public synchronized AccessToken
getXAuthAccessToken(String userid
, String password
) throws WeiboException
{
1635 return getXAuthAccessToken(userid
,password
,Constants
.X_AUTH_MODE
);
1639 * Sets the access token
1640 * @param accessToken accessToken
1641 * @since Weibo4J 1.2.1
1643 public void setOAuthAccessToken(AccessToken accessToken
){
1644 this.http
.setOAuthAccessToken(accessToken
);
1648 * Sets the access token
1649 * @param token token
1650 * @param tokenSecret token secret
1651 * @since Weibo4J 1.2.1
1653 public void setOAuthAccessToken(String token
, String tokenSecret
) {
1654 setOAuthAccessToken(new AccessToken(token
, tokenSecret
));
1660 /* Status Methods */
1663 public RateLimitStatus
getRateLimitStatus()throws
1665 /*modify by sycheng edit with json */
1666 return new RateLimitStatus(get(getBaseURL() +
1667 "account/rate_limit_status.json", true),this);
1676 * Returns the 20 most recent retweets posted by the authenticating user.
1678 * @return the 20 most recent retweets posted by the authenticating user
1679 * @throws WeiboException when Weibo service or network is unavailable
1680 * @since Weibo4J 1.2.1
1682 public List
<Status
> getRetweetedByMe() throws WeiboException
{
1683 return Status
.constructStatuses(get(getBaseURL() + "statuses/retweeted_by_me.json",
1685 /*return Status.constructStatuses(get(getBaseURL() + "statuses/retweeted_by_me.xml",
1686 null, true), this);*/
1690 * Returns the 20 most recent retweets posted by the authenticating user.
1691 * @param paging controls pagination
1692 * @return the 20 most recent retweets posted by the authenticating user
1693 * @throws WeiboException when Weibo service or network is unavailable
1694 * @since Weibo4J 1.2.1
1696 public List
<Status
> getRetweetedByMe(Paging paging
) throws WeiboException
{
1697 return Status
.constructStatuses(get(getBaseURL() + "statuses/retweeted_by_me.json",
1699 /*return Status.constructStatuses(get(getBaseURL() + "statuses/retweeted_by_me.xml",
1700 null, paging, true), this);*/
1704 * Returns the 20 most recent retweets posted by the authenticating user's friends.
1705 * @return the 20 most recent retweets posted by the authenticating user's friends.
1706 * @throws WeiboException when Weibo service or network is unavailable
1707 * @since Weibo4J 1.2.1
1709 public List
<Status
> getRetweetedToMe() throws WeiboException
{
1710 return Status
.constructStatuses(get(getBaseURL() + "statuses/retweeted_to_me.json",
1712 /*return Status.constructStatuses(get(getBaseURL() + "statuses/retweeted_to_me.xml",
1713 null, true), this);*/
1717 * Returns the 20 most recent retweets posted by the authenticating user's friends.
1718 * @param paging controls pagination
1719 * @return the 20 most recent retweets posted by the authenticating user's friends.
1720 * @throws WeiboException when Weibo service or network is unavailable
1721 * @since Weibo4J 1.2.1
1723 public List
<Status
> getRetweetedToMe(Paging paging
) throws WeiboException
{
1724 return Status
.constructStatuses(get(getBaseURL() + "statuses/retweeted_to_me.json",
1725 null, paging
, true));
1726 /*return Status.constructStatuses(get(getBaseURL() + "statuses/retweeted_to_me.xml",
1727 null, paging, true), this);*/
1731 * Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
1732 * @return the 20 most recent tweets of the authenticated user that have been retweeted by others.
1733 * @throws WeiboException when Weibo service or network is unavailable
1734 * @since Weibo4J 1.2.1
1736 public List
<Status
> getRetweetsOfMe() throws WeiboException
{
1737 return Status
.constructStatuses(get(getBaseURL() + "statuses/retweets_of_me.json",
1739 /*return Status.constructStatuses(get(getBaseURL() + "statuses/retweets_of_me.xml",
1740 null, true), this);*/
1744 * Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
1745 * @param paging controls pagination
1746 * @return the 20 most recent tweets of the authenticated user that have been retweeted by others.
1747 * @throws WeiboException when Weibo service or network is unavailable
1748 * @since Weibo4J 1.2.1
1750 public List
<Status
> getRetweetsOfMe(Paging paging
) throws WeiboException
{
1751 return Status
.constructStatuses(get(getBaseURL() + "statuses/retweets_of_me.json",
1752 null, paging
, true));
1753 /* return Status.constructStatuses(get(getBaseURL() + "statuses/retweets_of_me.xml",
1754 null, paging, true), this);*/
1759 * Retweets a tweet. Requires the id parameter of the tweet you are retweeting. Returns the original tweet with retweet details embedded.
1760 * @param statusId The ID of the status to retweet.
1761 * @return the retweeted status
1762 * @throws WeiboException when Weibo service or network is unavailable
1763 * @since Weibo4J 1.2.1
1765 public Status
retweetStatus(long statusId
) throws WeiboException
{
1766 /*return new Status(http.post(getBaseURL() + "statuses/retweet/" + statusId + ".xml",
1767 new PostParameter[0], true), this);*/
1768 return new Status(http
.post(getBaseURL() + "statuses/retweet/" + statusId
+ ".json",
1769 new PostParameter
[0], true));
1775 * Settings privacy information
1776 * @param comment (message&realname&geo&badge)
1778 * @throws WeiboException
1779 * @see<a href="http://open.t.sina.com.cn/wiki/index.php/Account/update_privacy">Account/update privacy</a>
1780 * @since Weibo4J 1.2.1
1784 public User
updatePrivacy(String comment
) throws WeiboException
{
1785 return new User(http
.post(getBaseURL() + "account/update_privacy.json",
1786 new PostParameter
[]{new PostParameter("comment", comment
)}, true).asJSONObject());
1798 * Returns a list of the users currently featured on the site with their current statuses inline.
1800 * @return List of User
1801 * @throws WeiboException when Weibo service or network is unavailable
1803 public List
<User
> getFeatured() throws WeiboException
{
1804 // return User.constructUsers(get(getBaseURL() + "statuses/featured.xml", true), this);
1805 return User
.constructUsers(get(getBaseURL() + "statuses/featured.json", true));
1819 * Tests if a friendship exists between two users.
1821 * @param userA The ID or screen_name of the first user to test friendship for.
1822 * @param userB The ID or screen_name of the second user to test friendship for.
1823 * @return if a friendship exists between two users.
1824 * @throws WeiboException when Weibo service or network is unavailable
1825 * @since Weibo4J 1.2.1
1826 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/exists">friendships/exists </a>
1828 public boolean existsFriendship(String userA
, String userB
) throws WeiboException
{
1829 return -1 != get(getBaseURL() + "friendships/exists.json", "user_a", userA
, "user_b", userB
, true).
1830 asString().indexOf("true");
1834 * Returns an array of numeric IDs for every user the authenticating user is following.
1835 * @return an array of numeric IDs for every user the authenticating user is following
1836 * @throws WeiboException when Weibo service or network is unavailable
1837 * @since Weibo4J 1.2.1
1838 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">friends/ids</a>
1839 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1841 public IDs
getFriendsIDs() throws WeiboException
{
1842 return getFriendsIDs(-1l);
1846 * Returns an array of numeric IDs for every user the authenticating user is following.
1847 * @param cursor Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
1848 * @return an array of numeric IDs for every user the authenticating user is following
1849 * @throws WeiboException when Weibo service or network is unavailable
1850 * @since Weibo4J 1.2.1
1851 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">friends/ids</a>
1852 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1854 public IDs
getFriendsIDs(long cursor
) throws WeiboException
{
1855 return new IDs(get(getBaseURL() + "friends/ids.xml?cursor=" + cursor
, true));
1859 * Returns an array of numeric IDs for every user the specified user is following.<br>
1860 * all IDs are attempted to be returned, but large sets of IDs will likely fail with timeout errors.
1861 * @param userId Specfies the ID of the user for whom to return the friends list.
1862 * @return an array of numeric IDs for every user the specified user is following
1863 * @throws WeiboException when Weibo service or network is unavailable
1864 * @since Weibo4J 1.2.1
1865 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">friends/ids</a>
1866 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1868 public IDs
getFriendsIDs(int userId
) throws WeiboException
{
1869 return getFriendsIDs(userId
, -1l);
1873 * Returns an array of numeric IDs for every user the specified user is following.
1874 * @param userId Specifies the ID of the user for whom to return the friends list.
1875 * @param cursor Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
1876 * @return an array of numeric IDs for every user the specified user is following
1877 * @throws WeiboException when Weibo service or network is unavailable
1878 * @since Weibo4J 1.2.1
1879 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">friends/ids</a>
1880 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1882 public IDs
getFriendsIDs(int userId
, long cursor
) throws WeiboException
{
1883 /*return new IDs(get(getBaseURL() + "friends/ids.xml?user_id=" + userId +
1884 "&cursor=" + cursor, true));*/
1885 return new IDs(get(getBaseURL() + "friends/ids.json?user_id=" + userId
+
1886 "&cursor=" + cursor
, true),this);
1890 * Returns an array of numeric IDs for every user the specified user is following.
1891 * @param screenName Specfies the screen name of the user for whom to return the friends list.
1892 * @return an array of numeric IDs for every user the specified user is following
1893 * @throws WeiboException when Weibo service or network is unavailable
1894 * @since Weibo4J 1.2.1
1895 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">friends/ids</a>
1896 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1898 public IDs
getFriendsIDs(String screenName
) throws WeiboException
{
1899 return getFriendsIDs(screenName
, -1l);
1903 * Returns an array of numeric IDs for every user the specified user is following.
1904 * @param screenName Specfies the screen name of the user for whom to return the friends list.
1905 * @param cursor Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
1906 * @return an array of numeric IDs for every user the specified user is following
1907 * @throws WeiboException when Weibo service or network is unavailable
1908 * @since Weibo4J 1.2.1
1909 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">friends/ids</a>
1910 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1912 public IDs
getFriendsIDs(String screenName
, long cursor
) throws WeiboException
{
1913 /* return new IDs(get(getBaseURL() + "friends/ids.xml?screen_name=" + screenName
1914 + "&cursor=" + cursor, true));*/
1915 return new IDs(get(getBaseURL() + "friends/ids.json?screen_name=" + screenName
1916 + "&cursor=" + cursor
, true),this);
1920 * Returns an array of numeric IDs for every user the specified user is followed by.
1921 * @return The ID or screen_name of the user to retrieve the friends ID list for.
1922 * @throws WeiboException when Weibo service or network is unavailable
1923 * @since Weibo4J 1.2.1
1924 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">followers/ids </a>
1925 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1927 public IDs
getFollowersIDs() throws WeiboException
{
1928 return getFollowersIDs(-1l);
1932 * Returns an array of numeric IDs for every user the specified user is followed by.
1933 * @return The ID or screen_name of the user to retrieve the friends ID list for.
1934 * @param cursor Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
1935 * @throws WeiboException when Weibo service or network is unavailable
1936 * @since Weibo4J 1.2.1
1937 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">followers/ids </a>
1938 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1940 public IDs
getFollowersIDs(long cursor
) throws WeiboException
{
1941 /*return new IDs(get(getBaseURL() + "followers/ids.xml?cursor=" + cursor
1943 return new IDs(get(getBaseURL() + "followers/ids.json?cursor=" + cursor
1948 * Returns an array of numeric IDs for every user the specified user is followed by.
1949 * @param userId Specfies the ID of the user for whom to return the followers list.
1950 * @return The ID or screen_name of the user to retrieve the friends ID list for.
1951 * @throws WeiboException when Weibo service or network is unavailable
1952 * @since Weibo4J 1.2.1
1953 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">followers/ids </a>
1954 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1956 public IDs
getFollowersIDs(int userId
) throws WeiboException
{
1957 return getFollowersIDs(userId
, -1l);
1961 * Returns an array of numeric IDs for every user the specified user is followed by.
1962 * @param userId Specifies the ID of the user for whom to return the followers list.
1963 * @param cursor Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
1964 * @return The ID or screen_name of the user to retrieve the friends ID list for.
1965 * @throws WeiboException when Weibo service or network is unavailable
1966 * @since Weibo4J 1.2.1
1967 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">followers/ids </a>
1968 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1970 public IDs
getFollowersIDs(int userId
, long cursor
) throws WeiboException
{
1971 return new IDs(get(getBaseURL() + "followers/ids.xml?user_id=" + userId
1972 + "&cursor=" + cursor
, true));
1976 * Returns an array of numeric IDs for every user the specified user is followed by.
1977 * @param screenName Specfies the screen name of the user for whom to return the followers list.
1978 * @return The ID or screen_name of the user to retrieve the friends ID list for.
1979 * @throws WeiboException when Weibo service or network is unavailable
1980 * @since Weibo4J 1.2.1
1981 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">followers/ids </a>
1982 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1984 public IDs
getFollowersIDs(String screenName
) throws WeiboException
{
1985 return getFollowersIDs(screenName
, -1l);
1989 * Returns an array of numeric IDs for every user the specified user is followed by.
1990 * @param screenName Specfies the screen name of the user for whom to return the followers list.
1991 * @param cursor Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
1992 * @return The ID or screen_name of the user to retrieve the friends ID list for.
1993 * @throws WeiboException when Weibo service or network is unavailable
1994 * @since Weibo4J 1.2.1
1995 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">followers/ids </a>
1996 * @deprecated use getFriendsIDS(String userid,String username,Paging paging) instead.
1998 public IDs
getFollowersIDs(String screenName
, long cursor
) throws WeiboException
{
1999 /* return new IDs(get(getBaseURL() + "followers/ids.xml?screen_name="
2000 + screenName + "&cursor=" + cursor, true));*/
2001 return new IDs(get(getBaseURL() + "followers/ids.json?screen_name="
2002 + screenName
+ "&cursor=" + cursor
, true),this);
2007 private void addParameterToList(List
<PostParameter
> colors
,
2008 String paramName
, String color
) {
2010 colors
.add(new PostParameter(paramName
,color
));
2017 * Enables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.
2020 * @throws WeiboException when Weibo service or network is unavailable
2021 * @since Weibo4J 1.2.1
2023 public User
enableNotification(String id
) throws WeiboException
{
2024 // return new User(http.post(getBaseURL() + "notifications/follow/" + id + ".xml", true), this);
2025 return new User(http
.post(getBaseURL() + "notifications/follow/" + id
+ ".json", true).asJSONObject());
2029 * Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.
2032 * @throws WeiboException when Weibo service or network is unavailable
2033 * @since Weibo4J 1.2.1
2035 public User
disableNotification(String id
) throws WeiboException
{
2036 // return new User(http.post(getBaseURL() + "notifications/leave/" + id + ".xml", true), this);
2037 return new User(http
.post(getBaseURL() + "notifications/leave/" + id
+ ".json", true).asJSONObject());
2042 /* Saved Searches Methods */
2044 * Returns the authenticated user's saved search queries.
2045 * @return Returns an array of numeric user ids the authenticating user is blocking.
2046 * @throws WeiboException when Weibo service or network is unavailable
2047 * @since Weibo4J 1.2.1
2049 public List
<SavedSearch
> getSavedSearches() throws WeiboException
{
2050 return SavedSearch
.constructSavedSearches(get(getBaseURL() + "saved_searches.json", true));
2054 * Retrieve the data for a saved search owned by the authenticating user specified by the given id.
2055 * @param id The id of the saved search to be retrieved.
2056 * @return the data for a saved search
2057 * @throws WeiboException when Weibo service or network is unavailable
2058 * @since Weibo4J 1.2.1
2060 public SavedSearch
showSavedSearch(int id
) throws WeiboException
{
2061 return new SavedSearch(get(getBaseURL() + "saved_searches/show/" + id
2066 * Retrieve the data for a saved search owned by the authenticating user specified by the given id.
2067 * @return the data for a created saved search
2068 * @throws WeiboException when Weibo service or network is unavailable
2069 * @since Weibo4J 1.2.1
2071 public SavedSearch
createSavedSearch(String query
) throws WeiboException
{
2072 return new SavedSearch(http
.post(getBaseURL() + "saved_searches/create.json"
2073 , new PostParameter
[]{new PostParameter("query", query
)}, true));
2077 * Destroys a saved search for the authenticated user. The search specified by id must be owned by the authenticating user.
2078 * @param id The id of the saved search to be deleted.
2079 * @return the data for a destroyed saved search
2080 * @throws WeiboException when Weibo service or network is unavailable
2081 * @since Weibo4J 1.2.1
2083 public SavedSearch
destroySavedSearch(int id
) throws WeiboException
{
2084 return new SavedSearch(http
.post(getBaseURL() + "saved_searches/destroy/" + id
2090 * Obtain the ListObject feed list
2091 * @param uid User ID or screen_name
2092 * @param listId The ID or slug of ListObject
2093 * @param auth if true, the request will be sent with BASIC authentication header
2095 * @throws WeiboException
2097 public List
<Status
> getListStatuses(String uid
, String listId
, boolean auth
) throws WeiboException
{
2098 StringBuilder sb
= new StringBuilder();
2099 sb
.append(getBaseURL()).append(uid
).append("/lists/").append(listId
).append("/statuses.xml").append("?source=").append(CONSUMER_KEY
);
2100 String httpMethod
= "GET";
2101 String url
= sb
.toString();
2103 return Status
.constructStatuses(http
.httpRequest(url
, null, auth
, httpMethod
), this);
2108 * Obtain ListObject member list
2109 * @param uid User ID or screen_name
2110 * @param listId The ID or slug of ListObject
2111 * @param auth if true, the request will be sent with BASIC authentication header
2113 * @throws WeiboException
2115 public UserWapper
getListMembers(String uid
, String listId
, boolean auth
) throws WeiboException
{
2116 StringBuilder sb
= new StringBuilder();
2117 sb
.append(getBaseURL()).append(uid
).append("/").append(listId
).append("/members.xml").append("?source=").append(CONSUMER_KEY
);
2118 String httpMethod
= "GET";
2119 String url
= sb
.toString();
2121 return User
.constructWapperUsers(http
.httpRequest(url
, null, auth
, httpMethod
), this);
2125 * Obtain ListObject subscribe user's list
2126 * @param uid User ID or screen_name
2127 * @param listId The ID or slug of ListObject
2128 * @param auth if true, the request will be sent with BASIC authentication header
2130 * @throws WeiboException
2132 public UserWapper
getListSubscribers(String uid
, String listId
, boolean auth
) throws WeiboException
{
2133 StringBuilder sb
= new StringBuilder();
2134 sb
.append(getBaseURL()).append(uid
).append("/").append(listId
).append("/subscribers.xml").append("?source=").append(CONSUMER_KEY
);
2135 String httpMethod
= "GET";
2136 String url
= sb
.toString();
2138 return User
.constructWapperUsers(http
.httpRequest(url
, null, auth
, httpMethod
), this);
2144 * confirm list member
2145 * @param uid User ID or screen_name
2146 * @param listId The ID or slug of ListObject
2147 * @param targetUid Target user ID or screen_name
2148 * @param auth if true, the request will be sent with BASIC authentication header
2150 * @throws WeiboException
2152 public boolean isListMember(String uid
, String listId
, String targetUid
, boolean auth
)
2153 throws WeiboException
{
2154 StringBuilder sb
= new StringBuilder();
2155 sb
.append(getBaseURL()).append(uid
).append("/").append(listId
).append("/members/").append(targetUid
)
2156 .append(".xml").append("?source=").append(CONSUMER_KEY
);
2157 String url
= sb
.toString();
2159 String httpMethod
= "GET";
2161 Document doc
= http
.httpRequest(url
, null, auth
, httpMethod
).asDocument();
2162 Element root
= doc
.getDocumentElement();
2163 return "true".equals(root
.getNodeValue());
2167 * confirm subscription list
2168 * @param uid User ID or screen_name
2169 * @param listId The ID or slug of ListObject
2170 * @param targetUid Target user ID or screen_name
2171 * @param auth if true, the request will be sent with BASIC authentication header
2173 * @throws WeiboException
2175 public boolean isListSubscriber(String uid
, String listId
, String targetUid
, boolean auth
)
2176 throws WeiboException
{
2177 StringBuilder sb
= new StringBuilder();
2178 sb
.append(getBaseURL()).append(uid
).append("/").append(listId
).append("/subscribers/").append(targetUid
)
2179 .append(".xml").append("?source=").append(CONSUMER_KEY
);
2180 String url
= sb
.toString();
2182 String httpMethod
= "GET";
2184 Document doc
= http
.httpRequest(url
, null, auth
, httpMethod
).asDocument();
2185 Element root
= doc
.getDocumentElement();
2186 return "true".equals(root
.getNodeValue());
2191 * Returns the string "ok" in the requested format with a 200 OK HTTP status code.
2192 * @return true if the API is working
2193 * @throws WeiboException when Weibo service or network is unavailable
2194 * @since Weibo4J 1.2.1
2196 public boolean test() throws WeiboException
{
2197 return -1 != get(getBaseURL() + "help/test.json", false).
2198 asString().indexOf("ok");
2201 private SimpleDateFormat format
= new SimpleDateFormat(
2202 "EEE, d MMM yyyy HH:mm:ss z", Locale
.ENGLISH
);
2205 public boolean equals(Object o
) {
2206 if (this == o
) return true;
2207 if (o
== null || getClass() != o
.getClass()) return false;
2209 Weibo weibo
= (Weibo
) o
;
2211 if (!baseURL
.equals(weibo
.baseURL
)) return false;
2212 if (!format
.equals(weibo
.format
)) return false;
2213 if (!http
.equals(weibo
.http
)) return false;
2214 if (!searchBaseURL
.equals(weibo
.searchBaseURL
)) return false;
2215 if (!source
.equals(weibo
.source
)) return false;
2221 public int hashCode() {
2222 int result
= http
.hashCode();
2223 result
= 31 * result
+ baseURL
.hashCode();
2224 result
= 31 * result
+ searchBaseURL
.hashCode();
2225 result
= 31 * result
+ source
.hashCode();
2226 result
= 31 * result
+ format
.hashCode();
2231 public String
toString() {
2234 ", baseURL='" + baseURL
+ '\'' +
2235 ", searchBaseURL='" + searchBaseURL
+ '\'' +
2236 ", source='" + source
+ '\'' +
2237 ", format=" + format
+
2247 * Return your relationship with the details of a user
2248 * @param target_id id of the befriended user
2249 * @return jsonObject
2250 * @throws WeiboException when Weibo service or network is unavailable
2252 public JSONObject
showFriendships(String target_id
) throws WeiboException
{
2253 return get(getBaseURL() + "friendships/show.json?target_id="+target_id
, true).asJSONObject();
2257 * Return the details of the relationship between two users
2258 * @param target_id id of the befriended user
2259 * @return jsonObject
2260 * @throws WeiboException when Weibo service or network is unavailable
2261 * @Ricky Add source parameter&missing "="
2263 public JSONObject
showFriendships(String source_id
,String target_id
) throws WeiboException
{
2264 return get(getBaseURL() + "friendships/show.json?target_id="+target_id
+"&source_id="+source_id
+"&source="+CONSUMER_KEY
, true).asJSONObject();
2270 * Return infomation of current user
2271 * @param ip a specified ip(Only open to invited partners)
2272 * @param args User Information args[2]:nickname,args[3]:gender,args[4],password,args[5]:email
2273 * @return jsonObject
2274 * @throws WeiboException when Weibo service or network is unavailable
2276 public JSONObject
register(String ip
,String
...args
) throws WeiboException
{
2277 return http
.post(getBaseURL() + "account/register.json",
2278 new PostParameter
[]{new PostParameter("nick", args
[2]),
2279 new PostParameter("gender", args
[3]),
2280 new PostParameter("password", args
[4]),
2281 new PostParameter("email", args
[5]),
2282 new PostParameter("ip", ip
)}, true).asJSONObject();
2288 //--------------base method----------
2291 format
.setTimeZone(TimeZone
.getTimeZone("GMT"));
2292 http
.setRequestTokenURL(Configuration
.getScheme() + "api.t.sina.com.cn/oauth/request_token");
2293 http
.setAuthorizationURL(Configuration
.getScheme() + "api.t.sina.com.cn/oauth/authorize");
2294 http
.setAccessTokenURL(Configuration
.getScheme() + "api.t.sina.com.cn/oauth/access_token");
2298 * Sets token information
2300 * @param tokenSecret
2302 public void setToken(String token
, String tokenSecret
) {
2303 http
.setToken(token
, tokenSecret
);
2306 public Weibo(String baseURL
) {
2308 this.baseURL
= baseURL
;
2311 // public Weibo(String id, String password) {
2314 // setPassword(password);
2317 // public Weibo(String id, String password, String baseURL) {
2320 // setPassword(password);
2321 // this.baseURL = baseURL;
2327 * @param baseURL String the base URL
2329 public void setBaseURL(String baseURL
) {
2330 this.baseURL
= baseURL
;
2334 * Returns the base URL
2336 * @return the base URL
2338 public String
getBaseURL() {
2339 return this.baseURL
;
2343 * Sets the search base URL
2345 * @param searchBaseURL the search base URL
2346 * @since Weibo4J 1.2.1
2348 public void setSearchBaseURL(String searchBaseURL
) {
2349 this.searchBaseURL
= searchBaseURL
;
2353 * Returns the search base url
2354 * @return search base url
2355 * @since Weibo4J 1.2.1
2357 public String
getSearchBaseURL(){
2358 return this.searchBaseURL
;
2362 * Issues an HTTP GET request.
2364 * @param url the request url
2365 * @param authenticate if true, the request will be sent with BASIC authentication header
2366 * @return the response
2367 * @throws WeiboException when Weibo service or network is unavailable
2370 private Response
get(String url
, boolean authenticate
) throws WeiboException
{
2371 return get(url
, null, authenticate
);
2375 * Issues an HTTP GET request.
2377 * @param url the request url
2378 * @param authenticate if true, the request will be sent with BASIC authentication header
2379 * @param name1 the name of the first parameter
2380 * @param value1 the value of the first parameter
2381 * @return the response
2382 * @throws WeiboException when Weibo service or network is unavailable
2385 protected Response
get(String url
, String name1
, String value1
, boolean authenticate
) throws WeiboException
{
2386 return get(url
, new PostParameter
[]{new PostParameter(name1
, value1
)}, authenticate
);
2390 * Issues an HTTP GET request.
2392 * @param url the request url
2393 * @param name1 the name of the first parameter
2394 * @param value1 the value of the first parameter
2395 * @param name2 the name of the second parameter
2396 * @param value2 the value of the second parameter
2397 * @param authenticate if true, the request will be sent with BASIC authentication header
2398 * @return the response
2399 * @throws WeiboException when Weibo service or network is unavailable
2402 protected Response
get(String url
, String name1
, String value1
, String name2
, String value2
, boolean authenticate
) throws WeiboException
{
2403 return get(url
, new PostParameter
[]{new PostParameter(name1
, value1
), new PostParameter(name2
, value2
)}, authenticate
);
2407 * Issues an HTTP GET request.
2409 * @param url the request url
2410 * @param params the request parameters
2411 * @param authenticate if true, the request will be sent with BASIC authentication header
2412 * @return the response
2413 * @throws WeiboException when Weibo service or network is unavailable
2415 protected Response
get(String url
, PostParameter
[] params
, boolean authenticate
) throws WeiboException
{
2416 if (null != params
&& params
.length
> 0) {
2417 String encodedParams
= HttpClient
.encodeParameters(params
);
2418 if (-1 == url
.indexOf("?")) {
2419 url
+= "?" + encodedParams
;
2421 url
+= "&" + encodedParams
;
2424 return http
.get(url
, authenticate
);
2428 * Issues an HTTP GET request.
2430 * @param url the request url
2431 * @param params the request parameters
2432 * @param paging controls pagination
2433 * @param authenticate if true, the request will be sent with BASIC authentication header
2434 * @return the response
2435 * @throws WeiboException when Weibo service or network is unavailable
2437 protected Response
get(String url
, PostParameter
[] params
, Paging paging
, boolean authenticate
) throws WeiboException
{
2438 if (null != paging
) {
2439 List
<PostParameter
> pagingParams
= new ArrayList
<PostParameter
>(4);
2440 if (-1 != paging
.getMaxId()) {
2441 pagingParams
.add(new PostParameter("max_id", String
.valueOf(paging
.getMaxId())));
2443 if (-1 != paging
.getSinceId()) {
2444 pagingParams
.add(new PostParameter("since_id", String
.valueOf(paging
.getSinceId())));
2446 if (-1 != paging
.getPage()) {
2447 pagingParams
.add(new PostParameter("page", String
.valueOf(paging
.getPage())));
2449 if (-1 != paging
.getCount()) {
2450 if (-1 != url
.indexOf("search")) {
2451 // search api takes "rpp"
2452 pagingParams
.add(new PostParameter("rpp", String
.valueOf(paging
.getCount())));
2454 pagingParams
.add(new PostParameter("count", String
.valueOf(paging
.getCount())));
2457 PostParameter
[] newparams
= null;
2458 PostParameter
[] arrayPagingParams
= pagingParams
.toArray(new PostParameter
[pagingParams
.size()]);
2459 if (null != params
) {
2460 newparams
= new PostParameter
[params
.length
+ pagingParams
.size()];
2461 System
.arraycopy(params
, 0, newparams
, 0, params
.length
);
2462 System
.arraycopy(arrayPagingParams
, 0, newparams
, params
.length
, pagingParams
.size());
2464 if (0 != arrayPagingParams
.length
) {
2465 String encodedParams
= HttpClient
.encodeParameters(arrayPagingParams
);
2466 if (-1 != url
.indexOf("?")) {
2467 url
+= "&source=" + CONSUMER_KEY
+
2468 "&" + encodedParams
;
2470 url
+= "?source=" + CONSUMER_KEY
+
2471 "&" + encodedParams
;
2475 return get(url
, newparams
, authenticate
);
2477 return get(url
, params
, authenticate
);
2481 private PostParameter
[] generateParameterArray(Map
<String
, String
> parames
)
2482 throws WeiboException
{
2483 PostParameter
[] array
= new PostParameter
[parames
.size()];
2485 for (String key
: parames
.keySet()) {
2486 if (parames
.get(key
) != null) {
2487 array
[i
] = new PostParameter(key
, parames
.get(key
));
2493 public final static Device IM
= new Device("im");
2494 public final static Device SMS
= new Device("sms");
2495 public final static Device NONE
= new Device("none");
2497 static class Device
{
2498 final String DEVICE
;
2500 public Device(String device
) {
2504 //---------------@deprecated---------------------------------------
2507 * Returns the user's friends, each with current status inline.
2508 * <br>This method calls http://api.t.sina.com.cn/statuses/friends.format
2510 * @param id the ID or screen name of the user for whom to request a list of friends
2511 * @param paging controls pagination
2512 * @return the list of friends
2513 * @throws WeiboException when Weibo service or network is unavailable
2514 * @since Weibo4J 1.2.1
2515 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
2516 * @deprecated use getFriendsStatuses(id,paging) instead
2518 public List
<User
> getFriends(String id
, Paging paging
) throws WeiboException
{
2519 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2524 * Returns the user's friends, each with current status inline.
2525 * <br>This method calls http://api.t.sina.com.cn/statuses/friends.format
2527 * @param id the ID or screen name of the user for whom to request a list of friends
2528 * @param page the number of page
2530 * @throws WeiboException when Weibo service or network is unavailable
2531 * @deprecated Use getFriendsStatuses(String id, Paging paging) instead
2532 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
2534 public List
<User
> getFriends(String id
, int page
) throws WeiboException
{
2535 return getFriendsStatuses(id
, page
);
2540 * Returns the specified user's friends, each with current status inline.
2541 * <br>This method calls http://api.t.sina.com.cn/statuses/friends.format
2543 * @param page number of page
2544 * @return the list of friends
2545 * @throws WeiboException when Weibo service or network is unavailable
2546 * @deprecated Use getFriendsStatuses(Paging paging) instead
2547 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
2549 public List
<User
> getFriends(int page
) throws WeiboException
{
2550 return getFriendsStatuses(page
);
2555 * Returns the specified user's friends, each with current status inline.
2556 * <br>This method calls http://api.t.sina.com.cn/statuses/friends.format
2558 * @return the list of friends
2559 * @throws WeiboException when Weibo service or network is unavailable
2560 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
2561 * @deprecated use getFriendsStatues() instead
2563 public List
<User
> getFriends() throws WeiboException
{
2564 return getFriendsStatuses();
2569 * Returns the specified user's friends, each with current status inline.
2570 * <br>This method calls http://api.t.sina.com.cn/statuses/friends.format
2572 * @param paging controls pagination
2573 * @return the list of friends
2574 * @throws WeiboException when Weibo service or network is unavailable
2575 * @since Weibo4J 1.2.1
2576 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
2577 * @deprecated Use getFriendsStatuses(Paging paging) instead
2579 public List
<User
> getFriends(Paging paging
) throws WeiboException
{
2580 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2585 * Returns the user's friends, each with current status inline.
2586 * <br>This method calls http://api.t.sina.com.cn/statuses/friends.format
2588 * @param id the ID or screen name of the user for whom to request a list of friends
2589 * @return the list of friends
2590 * @throws WeiboException when Weibo service or network is unavailable
2591 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends">statuses/friends </a>
2592 * @deprecated use getFriendsStatuses(id) instead
2594 public List
<User
> getFriends(String id
) throws WeiboException
{
2595 return getFriendsStatuses(id
);
2600 * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they joined Weibo (this is going to be changed).
2601 * <br>This method calls http://api.t.sina.com.cn/statuses/followers.format
2603 * @param id The ID or screen name of the user for whom to request a list of followers.
2604 * @param paging controls pagination
2606 * @throws WeiboException when Weibo service or network is unavailable
2607 * @since Weibo4J 1.2.1
2608 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
2609 * @deprecated use getFollowersStatuses(id) instead
2611 public List
<User
> getFollowers(String id
, Paging paging
) throws WeiboException
{
2612 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2617 * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they joined Weibo (this is going to be changed).
2618 * <br>This method calls http://api.t.sina.com.cn/statuses/followers.format
2620 * @param id The ID or screen name of the user for whom to request a list of followers.
2621 * @param page Retrieves the next 100 followers.
2623 * @throws WeiboException when Weibo service or network is unavailable
2624 * @since Weibo4J 1.2.1
2625 * @deprecated Use getFollowersStatuses(String id, Paging paging) instead
2626 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
2628 public List
<User
> getFollowers(String id
, int page
) throws WeiboException
{
2629 return getFollowersStatuses(id
, page
);
2634 * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they joined Weibo (this is going to be changed).
2635 * <br>This method calls http://api.t.sina.com.cn/statuses/followers.format
2638 * @throws WeiboException when Weibo service or network is unavailable
2639 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
2640 * @deprecated use getFollowersStatuses() instead
2642 public List
<User
> getFollowers() throws WeiboException
{
2643 return getFollowersStatuses();
2648 * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they joined Weibo (this is going to be changed).
2649 * <br>This method calls http://api.t.sina.com.cn/statuses/followers.format
2651 * @param paging controls pagination
2653 * @throws WeiboException when Weibo service or network is unavailable
2654 * @since Weibo4J 1.2.1
2655 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
2656 * @deprecated use getFollowersStatuses(paging)
2658 public List
<User
> getFollowers(Paging paging
) throws WeiboException
{
2659 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2664 * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they joined Weibo (this is going to be changed).
2665 * <br>This method calls http://api.t.sina.com.cn/statuses/followers.format
2667 * @param page Retrieves the next 100 followers.
2669 * @throws WeiboException when Weibo service or network is unavailable
2670 * @since Weibo4J 1.2.1
2671 * @deprecated Use getFollowersStatuses(Paging paging) instead
2672 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
2674 public List
<User
> getFollowers(int page
) throws WeiboException
{
2675 return getFollowersStatuses(page
);
2680 * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they joined Weibo (this is going to be changed).
2681 * <br>This method calls http://api.t.sina.com.cn/statuses/followers.format
2683 * @param id The ID or screen name of the user for whom to request a list of followers.
2685 * @throws WeiboException when Weibo service or network is unavailable
2686 * @since Weibo4J 1.2.1
2687 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/followers">statuses/followers </a>
2688 * @deprecated use getFollowersStatuses(id) instead
2690 public List
<User
> getFollowers(String id
) throws WeiboException
{
2691 return getFollowersStatuses(id
);
2696 * Returns only public statuses with an ID greater than (that is, more recent than) the specified ID.
2697 * <br>This method calls http://api.t.sina.com.cn/statuses/public_timeline.format
2699 * @param sinceID returns only public statuses with an ID greater than (that is, more recent than) the specified ID
2700 * @return the 20 most recent statuses
2701 * @throws WeiboException when Weibo service or network is unavailable
2702 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/public_timeline">statuses/public_timeline </a>
2703 * @deprecated use getPublicTimeline(long sinceID) instead
2705 public List
<Status
> getPublicTimeline(int sinceID
) throws
2707 return getPublicTimeline((long)sinceID
);
2712 * Returns only public statuses with an ID greater than (that is, more recent than) the specified ID.
2713 * <br>This method calls http://api.t.sina.com.cn/statuses/public_timeline.format
2715 * @param sinceID returns only public statuses with an ID greater than (that is, more recent than) the specified ID
2716 * @return the 20 most recent statuses
2717 * @throws WeiboException when Weibo service or network is unavailable
2718 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/public_timeline">statuses/public_timeline </a>
2719 * @deprecated user getPublicTimeline(int count,int baseApp) instead
2721 public List
<Status
> getPublicTimeline(long sinceID
) throws
2723 return Status
.constructStatuses(get(getBaseURL() +
2724 "statuses/public_timeline.json", null, new Paging((long) sinceID
)
2730 * Returns the 20 most recent statuses posted in the last 24 hours from the authenticating user.
2731 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2733 * @param page the number of page
2734 * @return list of the Friends Timeline
2735 * @throws WeiboException when Weibo service or network is unavailable
2736 * @deprecated Use getFriendsTimeline(Paging paging) instead
2737 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2739 public List
<Status
> getFriendsTimelineByPage(int page
) throws
2741 return getFriendsTimeline(new Paging(page
));
2746 * Returns the 20 most recent statuses posted in the last 24 hours from the authenticating user.
2747 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2749 * @param page the number of page
2750 * @return list of the Friends Timeline
2751 * @throws WeiboException when Weibo service or network is unavailable
2752 * @since Weibo4J 1.2.1
2753 * @deprecated Use getFriendsTimeline(Paging paging) instead
2754 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2756 public List
<Status
> getFriendsTimeline(int page
) throws
2758 return getFriendsTimeline(new Paging(page
));
2763 * Returns the 20 most recent statuses posted in the last 24 hours from the authenticating user.
2764 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2766 * @param sinceId Returns only statuses with an ID greater than (that is, more recent than) the specified ID
2767 * @param page the number of page
2768 * @return list of the Friends Timeline
2769 * @throws WeiboException when Weibo service or network is unavailable
2770 * @since Weibo4J 1.2.1
2771 * @deprecated Use getFriendsTimeline(Paging paging) instead
2772 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2774 public List
<Status
> getFriendsTimeline(long sinceId
, int page
) throws
2776 return getFriendsTimeline(new Paging(page
).sinceId(sinceId
));
2781 * Returns the 20 most recent statuses posted in the last 24 hours from the specified userid.
2782 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2784 * @param id specifies the ID or screen name of the user for whom to return the friends_timeline
2785 * @return list of the Friends Timeline
2786 * @throws WeiboException when Weibo service or network is unavailable
2787 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2788 * @deprecated The Weibo API does not support this method anymore.
2790 public List
<Status
> getFriendsTimeline(String id
) throws
2792 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2797 * Returns the 20 most recent statuses posted in the last 24 hours from the specified userid.
2798 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2800 * @param id specifies the ID or screen name of the user for whom to return the friends_timeline
2801 * @param page the number of page
2802 * @return list of the Friends Timeline
2803 * @throws WeiboException when Weibo service or network is unavailable
2804 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2805 * @deprecated The Weibo API does not support this method anymore.
2807 public List
<Status
> getFriendsTimelineByPage(String id
, int page
) throws
2809 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2814 * Returns the 20 most recent statuses posted in the last 24 hours from the specified userid.
2815 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2817 * @param id specifies the ID or screen name of the user for whom to return the friends_timeline
2818 * @param page the number of page
2819 * @return list of the Friends Timeline
2820 * @throws WeiboException when Weibo service or network is unavailable
2821 * @since Weibo4J 1.2.1
2822 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2823 * @deprecated The Weibo API does not support this method anymore.
2825 public List
<Status
> getFriendsTimeline(String id
, int page
) throws
2827 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2832 * Returns the 20 most recent statuses posted in the last 24 hours from the specified userid.
2833 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2835 * @param sinceId Returns only statuses with an ID greater than (that is, more recent than) the specified ID
2836 * @param id specifies the ID or screen name of the user for whom to return the friends_timeline
2837 * @param page the number of page
2838 * @return list of the Friends Timeline
2839 * @throws WeiboException when Weibo service or network is unavailable
2840 * @since Weibo4J 1.2.1
2841 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2842 * @deprecated The Weibo API does not support this method anymore.
2844 public List
<Status
> getFriendsTimeline(long sinceId
, String id
, int page
) throws
2846 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2851 * Returns the 20 most recent statuses posted in the last 24 hours from the specified userid.
2852 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2854 * @param id specifies the ID or screen name of the user for whom to return the friends_timeline
2855 * @param paging controls pagination
2856 * @return list of the Friends Timeline
2857 * @throws WeiboException when Weibo service or network is unavailable
2858 * @since Weibo4J 1.2.1
2859 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2860 * @deprecated The Weibo API does not support this method anymore.
2862 public List
<Status
> getFriendsTimeline(String id
, Paging paging
) throws
2864 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2869 * Returns the 20 most recent statuses posted in the last 24 hours from the authenticating user.
2870 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2872 * @param since narrows the returned results to just those statuses created after the specified HTTP-formatted date
2873 * @return list of the Friends Timeline
2874 * @throws WeiboException when Weibo service or network is unavailable
2875 * @deprecated Use getFriendsTimeline(Paging paging) instead
2876 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2878 public List
<Status
> getFriendsTimeline(Date since
) throws
2880 return Status
.constructStatuses(get(getBaseURL() + "statuses/friends_timeline.xml",
2881 "since", format
.format(since
), true), this);
2886 * Returns the 20 most recent statuses posted in the last 24 hours from the authenticating user.
2887 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2889 * @param sinceId Returns only statuses with an ID greater than (that is, more recent than) the specified ID
2890 * @return list of the Friends Timeline
2891 * @throws WeiboException when Weibo service or network is unavailable
2892 * @since Weibo4J 1.2.1
2893 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2894 * @deprecated Use getFriendsTimeline(Paging paging) instead
2896 public List
<Status
> getFriendsTimeline(long sinceId
) throws
2898 return Status
.constructStatuses(get(getBaseURL() + "statuses/friends_timeline.xml",
2899 "since_id", String
.valueOf(sinceId
), true), this);
2904 * Returns the most recent statuses posted in the last 24 hours from the specified userid.
2905 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2907 * @param id specifies the ID or screen name of the user for whom to return the friends_timeline
2908 * @param since narrows the returned results to just those statuses created after the specified HTTP-formatted date
2909 * @return list of the Friends Timeline
2910 * @throws WeiboException when Weibo service or network is unavailable
2911 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2912 * @deprecated The Weibo API does not support this method anymore.
2914 public List
<Status
> getFriendsTimeline(String id
,Date since
) throws WeiboException
{
2915 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2920 * Returns the most recent statuses posted in the last 24 hours from the specified userid.
2921 * <br>This method calls http://api.t.sina.com.cn/statuses/friends_timeline.format
2923 * @param id specifies the ID or screen name of the user for whom to return the friends_timeline
2924 * @param sinceId Returns only statuses with an ID greater than (that is, more recent than) the specified ID
2925 * @return list of the Friends Timeline
2926 * @throws WeiboException when Weibo service or network is unavailable
2927 * @since Weibo4J 1.2.1
2928 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/friends_timeline"> statuses/friends_timeline </a>
2929 * @deprecated The Weibo API does not support this method anymore.
2931 public List
<Status
> getFriendsTimeline(String id
, long sinceId
) throws WeiboException
{
2932 throw new IllegalStateException("The Weibo API is not supporting this method anymore");
2937 * Returns the most recent statuses posted in the last 24 hours from the specified userid.
2938 * <br>This method calls http://api.t.sina.com.cn/statuses/user_timeline.format
2940 * @param id specifies the ID or screen name of the user for whom to return the user_timeline
2941 * @param count specifies the number of statuses to retrieve. May not be greater than 200 for performance purposes
2942 * @param since narrows the returned results to just those statuses created after the specified HTTP-formatted date
2943 * @return list of the user Timeline
2944 * @throws WeiboException when Weibo service or network is unavailable
2945 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
2946 * @deprecated using long sinceId is suggested.
2948 public List
<Status
> getUserTimeline(String id
, int count
2949 , Date since
) throws WeiboException
{
2950 return Status
.constructStatuses(get(getBaseURL() + "statuses/user_timeline/" + id
+ ".xml",
2951 "since", format
.format(since
), "count", String
.valueOf(count
), http
.isAuthenticationEnabled()), this);
2956 * Returns the most recent statuses posted in the last 24 hours from the specified userid.
2957 * <br>This method calls http://api.t.sina.com.cn/statuses/user_timeline.format
2959 * @param id specifies the ID or screen name of the user for whom to return the user_timeline
2960 * @param count specifies the number of statuses to retrieve. May not be greater than 200 for performance purposes
2961 * @param sinceId Returns only statuses with an ID greater than (that is, more recent than) the specified ID
2962 * @return list of the user Timeline
2963 * @throws WeiboException when Weibo service or network is unavailable
2964 * @since Weibo4J 1.2.1
2965 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
2966 * @deprecated Use getUserTimeline(String id, Paging paging) instead
2968 public List
<Status
> getUserTimeline(String id
, int count
,long sinceId
) throws WeiboException
{
2969 return getUserTimeline(id
, new Paging(sinceId
).count(count
));
2974 * Returns the most recent statuses posted in the last 24 hours from the specified userid.
2975 * <br>This method calls http://api.t.sina.com.cn/statuses/user_timeline.format
2977 * @param id specifies the ID or screen name of the user for whom to return the user_timeline
2978 * @param since narrows the returned results to just those statuses created after the specified HTTP-formatted date
2979 * @return the 20 most recent statuses posted in the last 24 hours from the user
2980 * @throws WeiboException when Weibo service or network is unavailable
2981 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
2982 * @deprecated Use getUserTimeline(String id, Paging paging) instead
2984 public List
<Status
> getUserTimeline(String id
, Date since
) throws WeiboException
{
2985 return Status
.constructStatuses(get(getBaseURL() + "statuses/user_timeline/" + id
+ ".xml",
2986 "since", format
.format(since
), http
.isAuthenticationEnabled()), this);
2991 * Returns the most recent statuses posted in the last 24 hours from the specified userid.
2992 * <br>This method calls http://api.t.sina.com.cn/statuses/user_timeline.format
2994 * @param id specifies the ID or screen name of the user for whom to return the user_timeline
2995 * @param count specifies the number of statuses to retrieve. May not be greater than 200 for performance purposes
2996 * @return the 20 most recent statuses posted in the last 24 hours from the user
2997 * @throws WeiboException when Weibo service or network is unavailable
2998 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
2999 * @deprecated Use getUserTimeline(String id, Paging paging) instead
3001 public List
<Status
> getUserTimeline(String id
, int count
) throws
3003 return Status
.constructStatuses(get(getBaseURL() + "statuses/user_timeline/" + id
+ ".xml",
3004 "count", String
.valueOf(count
), http
.isAuthenticationEnabled()), this);
3009 * Returns the most recent statuses posted in the last 24 hours from the authenticating user.
3010 * <br>This method calls http://api.t.sina.com.cn/statuses/user_timeline.format
3012 * @param count specifies the number of statuses to retrieve. May not be greater than 200 for performance purposes
3013 * @param since narrows the returned results to just those statuses created after the specified HTTP-formatted date
3014 * @return the 20 most recent statuses posted in the last 24 hours from the user
3015 * @throws WeiboException when Weibo service or network is unavailable
3016 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
3017 * @deprecated using long sinceId is suggested.
3019 public List
<Status
> getUserTimeline(int count
, Date since
) throws WeiboException
{
3020 return Status
.constructStatuses(get(getBaseURL() + "statuses/user_timeline.xml",
3021 "since", format
.format(since
), "count", String
.valueOf(count
), true), this);
3026 * Returns the most recent statuses posted in the last 24 hours from the authenticating user.
3027 * <br>This method calls http://api.t.sina.com.cn/statuses/user_timeline.format
3029 * @param count specifies the number of statuses to retrieve. May not be greater than 200 for performance purposes
3030 * @param sinceId returns only statuses with an ID greater than (that is, more recent than) the specified ID.
3031 * @return the 20 most recent statuses posted in the last 24 hours from the user
3032 * @throws WeiboException when Weibo service or network is unavailable
3033 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
3034 * @since Weibo4J 1.2.1
3035 * @deprecated Use getUserTimeline(String id, Paging paging) instead
3037 public List
<Status
> getUserTimeline(int count
, long sinceId
) throws WeiboException
{
3038 return getUserTimeline(new Paging(sinceId
).count(count
));
3043 * Returns the most recent statuses posted in the last 24 hours from the specified userid.
3044 * <br>This method calls http://api.t.sina.com.cn/statuses/user_timeline.format
3046 * @param id specifies the ID or screen name of the user for whom to return the user_timeline
3047 * @param sinceId returns only statuses with an ID greater than (that is, more recent than) the specified ID.
3048 * @return the 20 most recent statuses posted in the last 24 hours from the user
3049 * @throws WeiboException when Weibo service or network is unavailable
3050 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
3051 * @since Weibo4J 1.2.1
3052 * @deprecated Use getUserTimeline(String id, Paging paging) instead
3054 public List
<Status
> getUserTimeline(String id
, long sinceId
) throws WeiboException
{
3055 return getUserTimeline(id
, new Paging(sinceId
));
3060 * Returns the most recent statuses posted in the last 24 hours from the authenticating user.
3061 * <br>This method calls http://api.t.sina.com.cn/statuses/user_timeline.format
3063 * @param sinceId returns only statuses with an ID greater than (that is, more recent than) the specified ID.
3064 * @return the 20 most recent statuses posted in the last 24 hours from the user
3065 * @throws WeiboException when Weibo service or network is unavailable
3066 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/user_timeline">statuses/user_timeline</a>
3067 * @since Weibo4J 1.2.1
3068 * @deprecated Use getUserTimeline(Paging paging) instead
3070 public List
<Status
> getUserTimeline(long sinceId
) throws
3072 return getUserTimeline(new Paging(sinceId
));
3078 * @param status 要发布的微博消息文本内容
3079 * @return the latest status
3080 * @throws WeiboException when Weibo service or network is unavailable
3081 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/update">statuses/update </a>
3082 * @deprecated Use updateStatus(String status) instead
3084 public Status
update(String status
) throws WeiboException
{
3085 return updateStatus(status
);
3091 * @param status 要发布的微博消息文本内容
3092 * @param inReplyToStatusId 要转发的微博消息ID
3093 * @throws WeiboException when Weibo service or network is unavailable
3094 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/update">statuses/update </a>
3095 * @deprecated Use updateStatus(String status, long inReplyToStatusId) instead
3097 public Status
update(String status
, long inReplyToStatusId
) throws WeiboException
{
3098 return updateStatus(status
, inReplyToStatusId
);
3103 * Returns the 20 most recent replies (status updates prefixed with @username) to the authenticating user. Replies are only available to the authenticating user; you can not request a list of replies to another user whether public or protected.
3104 * <br>This method calls http://api.t.sina.com.cn/statuses/reply.format
3106 * @return the 20 most recent replies
3107 * @throws WeiboException when Weibo service or network is unavailable
3108 * @deprecated Use getMentions() instead
3109 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/reply">statuses/reply </a>
3111 public List
<Status
> getReplies() throws WeiboException
{
3112 return Status
.constructStatuses(get(getBaseURL() + "statuses/replies.xml", true), this);
3117 * Returns the 20 most recent replies (status updates prefixed with @username) to the authenticating user. Replies are only available to the authenticating user; you can not request a list of replies to another user whether public or protected.
3118 * <br>This method calls http://api.t.sina.com.cn/statuses/reply.format
3120 * @param sinceId Returns only statuses with an ID greater than (that is, more recent than) the specified ID
3121 * @return the 20 most recent replies
3122 * @throws WeiboException when Weibo service or network is unavailable
3123 * @since Weibo4J 1.2.1
3124 * @deprecated Use getMentions(Paging paging) instead
3125 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/reply">statuses/reply </a>
3127 public List
<Status
> getReplies(long sinceId
) throws WeiboException
{
3128 return Status
.constructStatuses(get(getBaseURL() + "statuses/replies.xml",
3129 "since_id", String
.valueOf(sinceId
), true), this);
3134 * Returns the most recent replies (status updates prefixed with @username) to the authenticating user. Replies are only available to the authenticating user; you can not request a list of replies to another user whether public or protected.
3135 * <br>This method calls http://api.t.sina.com.cn/statuses/reply.format
3137 * @param page the number of page
3138 * @return the 20 most recent replies
3139 * @throws WeiboException when Weibo service or network is unavailable
3140 * @deprecated Use getMentions(Paging paging) instead
3141 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/reply">statuses/reply </a>
3143 public List
<Status
> getRepliesByPage(int page
) throws WeiboException
{
3145 throw new IllegalArgumentException("page should be positive integer. passed:" + page
);
3147 return Status
.constructStatuses(get(getBaseURL() + "statuses/replies.xml",
3148 "page", String
.valueOf(page
), true), this);
3153 * Returns the most recent replies (status updates prefixed with @username) to the authenticating user. Replies are only available to the authenticating user; you can not request a list of replies to another user whether public or protected.
3154 * <br>This method calls http://api.t.sina.com.cn/statuses/reply.format
3156 * @param page the number of page
3157 * @return the 20 most recent replies
3158 * @throws WeiboException when Weibo service or network is unavailable
3159 * @since Weibo4J 1.2.1
3160 * @deprecated Use getMentions(Paging paging) instead
3161 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/reply">statuses/reply </a>
3163 public List
<Status
> getReplies(int page
) throws WeiboException
{
3165 throw new IllegalArgumentException("page should be positive integer. passed:" + page
);
3167 return Status
.constructStatuses(get(getBaseURL() + "statuses/replies.xml",
3168 "page", String
.valueOf(page
), true), this);
3173 * Returns the most recent replies (status updates prefixed with @username) to the authenticating user. Replies are only available to the authenticating user; you can not request a list of replies to another user whether public or protected.
3174 * <br>This method calls http://api.t.sina.com.cn/statuses/reply.format
3176 * @param sinceId Returns only statuses with an ID greater than (that is, more recent than) the specified ID
3177 * @param page the number of page
3178 * @return the 20 most recent replies
3179 * @throws WeiboException when Weibo service or network is unavailable
3180 * @since Weibo4J 1.2.1
3181 * @deprecated Use getMentions(Paging paging) instead
3182 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/reply">statuses/reply </a>
3184 public List
<Status
> getReplies(long sinceId
, int page
) throws WeiboException
{
3186 throw new IllegalArgumentException("page should be positive integer. passed:" + page
);
3188 return Status
.constructStatuses(get(getBaseURL() + "statuses/replies.xml",
3189 "since_id", String
.valueOf(sinceId
),
3190 "page", String
.valueOf(page
), true), this);
3195 * Returns a single status, specified by the id parameter. The status's author will be returned inline.
3196 * @param id the numerical ID of the status you're trying to retrieve
3197 * @return a single status
3198 * @throws WeiboException when Weibo service or network is unavailable
3199 * @deprecated Use showStatus(long id) instead.
3201 public Status
show(int id
) throws WeiboException
{
3202 return showStatus((long)id
);
3207 * Returns a single status, specified by the id parameter. The status's author will be returned inline.
3208 * <br>This method calls http://api.t.sina.com.cn/statuses/show/id.format
3210 * @param id the numerical ID of the status you're trying to retrieve
3211 * @return a single status
3212 * @throws WeiboException when Weibo service or network is unavailable
3213 * @since Weibo4J 1.2.1
3214 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Statuses/show">statuses/show </a>
3215 * @deprecated Use showStatus(long id) instead.
3218 public Status
show(long id
) throws WeiboException
{
3219 return new Status(get(getBaseURL() + "statuses/show/" + id
+ ".xml", false), this);
3224 * Returns extended information of a given user, specified by ID or screen name as per the required id parameter below. This information includes design settings, so third party developers can theme their widgets according to a given user's preferences.
3225 * <br>This method calls http://api.t.sina.com.cn/users/show.format
3226 * @param id the ID or screen name of the user for whom to request the detail
3228 * @throws WeiboException when Weibo service or network is unavailable
3229 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Users/show">users/show </a>
3230 * @deprecated use showUser(id) instead
3232 public User
getUserDetail(String id
) throws WeiboException
{
3233 return showUser(id
);
3237 * Befriends the user specified in the ID parameter as the authenticating user. Returns the befriended user in the requested format when successful. Returns a string describing the failure condition when unsuccessful.
3239 * @param id the ID or screen name of the user to be befriended
3240 * @return the befriended user
3241 * @throws WeiboException when Weibo service or network is unavailable
3242 * @deprecated Use createFriendship(String id) instead
3243 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/create">friendships/create </a>
3246 public User
create(String id
) throws WeiboException
{
3247 return createFriendship(id
);
3252 * Discontinues friendship with the user specified in the ID parameter as the authenticating user. Returns the un-friended user in the requested format when successful. Returns a string describing the failure condition when unsuccessful.
3254 * @param id the ID or screen name of the user for whom to request a list of friends
3256 * @throws WeiboException when Weibo service or network is unavailable
3257 * @deprecated Use destroyFriendship(String id) instead
3258 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/destroy">friendships/destroy </a>
3260 public User
destroy(String id
) throws WeiboException
{
3261 return destroyFriendship(id
);
3266 * Tests if a friendship exists between two users.
3268 * @param userA The ID or screen_name of the first user to test friendship for.
3269 * @param userB The ID or screen_name of the second user to test friendship for.
3270 * @return if a friendship exists between two users.
3271 * @throws WeiboException when Weibo service or network is unavailable
3272 * @deprecated Use friendshipExists(String userA, String userB)
3273 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friendships/exists">friendships/exists </a>
3275 public boolean exists(String userA
, String userB
) throws WeiboException
{
3276 return existsFriendship(userA
, userB
);
3281 * Returns an array of numeric IDs for every user the authenticating user is following.
3282 * @param paging Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
3283 * @return an array of numeric IDs for every user the authenticating user is following
3284 * @throws WeiboException when Weibo service or network is unavailable
3285 * @since Weibo4J 1.2.1
3286 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">friends/ids</a>
3287 * @deprecated use getFriendsIDs(long cursor) instead
3289 public IDs
getFriendsIDs(Paging paging
) throws WeiboException
{
3290 return new IDs(get(getBaseURL() + "friends/ids.xml", null, paging
, true));
3295 * Returns an array of numeric IDs for every user the specified user is following.
3296 * @param userId Specifies the ID of the user for whom to return the friends list.
3297 * @param paging Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
3298 * @return an array of numeric IDs for every user the specified user is following
3299 * @throws WeiboException when Weibo service or network is unavailable
3300 * @since Weibo4J 1.2.1
3301 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">friends/ids</a>
3302 * @deprecated use getFriendsIDs(int userId, long cursor) instead
3304 public IDs
getFriendsIDs(int userId
, Paging paging
) throws WeiboException
{
3305 return new IDs(get(getBaseURL() + "friends/ids.xml?user_id=" + userId
, null
3311 * Returns an array of numeric IDs for every user the specified user is following.
3312 * @param screenName Specfies the screen name of the user for whom to return the friends list.
3313 * @param paging Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
3314 * @return an array of numeric IDs for every user the specified user is following
3315 * @throws WeiboException when Weibo service or network is unavailable
3316 * @since Weibo4J 1.2.1
3317 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Friends/ids">friends/ids</a>
3318 * @deprecated use getFriendsIDs(String screenName, long cursor) instead
3320 public IDs
getFriendsIDs(String screenName
, Paging paging
) throws WeiboException
{
3321 return new IDs(get(getBaseURL() + "friends/ids.xml?screen_name=" + screenName
3322 , null, paging
, true));
3327 * Returns an array of numeric IDs for every user the specified user is followed by.
3328 * @return The ID or screen_name of the user to retrieve the friends ID list for.
3329 * @param paging Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
3330 * @throws WeiboException when Weibo service or network is unavailable
3331 * @since Weibo4J 1.2.1
3332 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">followers/ids </a>
3333 * @deprecated use getFollowersIDs(long cursor) instead
3335 public IDs
getFollowersIDs(Paging paging
) throws WeiboException
{
3336 return new IDs(get(getBaseURL() + "followers/ids.xml", null, paging
3342 * Returns an array of numeric IDs for every user the specified user is followed by.
3343 * @param userId Specfies the ID of the user for whom to return the followers list.
3344 * @param paging Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
3345 * @return The ID or screen_name of the user to retrieve the friends ID list for.
3346 * @throws WeiboException when Weibo service or network is unavailable
3347 * @since Weibo4J 1.2.1
3348 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">followers/ids </a>
3349 * @deprecated use getFollowersIDs(int userId, long cursor) instead
3351 public IDs
getFollowersIDs(int userId
, Paging paging
) throws WeiboException
{
3352 return new IDs(get(getBaseURL() + "followers/ids.xml?user_id=" + userId
, null
3358 * Returns an array of numeric IDs for every user the specified user is followed by.
3359 * @param screenName Specfies the screen name of the user for whom to return the followers list.
3360 * @param paging Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned.
3361 * @return The ID or screen_name of the user to retrieve the friends ID list for.
3362 * @throws WeiboException when Weibo service or network is unavailable
3363 * @since Weibo4J 1.2.1
3364 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Followers/ids">followers/ids </a>
3365 * @deprecated use getFollowersIDs(String screenName, long cursor) instead
3367 public IDs
getFollowersIDs(String screenName
, Paging paging
) throws WeiboException
{
3368 return new IDs(get(getBaseURL() + "followers/ids.xml?screen_name="
3369 + screenName
, null, paging
, true));
3374 * Updates the location
3376 * @param location the current location of the user
3377 * @return the updated user
3378 * @throws WeiboException when Weibo service or network is unavailable
3379 * @since Weibo4J 1.2.1
3380 * @deprecated Use updateProfile(String name, String email, String url, String location, String description) instead
3382 public User
updateLocation(String location
) throws WeiboException
{
3383 return new User(http
.post(getBaseURL() + "account/update_location.xml", new PostParameter
[]{new PostParameter("location", location
)}, true), this);
3388 * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
3389 * @return List<Status>
3390 * @throws WeiboException when Weibo service or network is unavailable
3391 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites">favorites </a>
3392 * @deprecated Use getFavorited() instead
3394 public List
<Status
> favorites() throws WeiboException
{
3395 return getFavorites();
3400 * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
3401 * @param page the number of page
3402 * @return List<Status>
3403 * @throws WeiboException when Weibo service or network is unavailable
3404 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites">favorites </a>
3405 * @deprecated Use getFavorites(int page) instead
3407 public List
<Status
> favorites(int page
) throws WeiboException
{
3408 return getFavorites(page
);
3413 * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
3415 * @param id the ID or screen name of the user for whom to request a list of favorite statuses
3416 * @return List<Status>
3417 * @throws WeiboException when Weibo service or network is unavailable
3418 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites">favorites </a>
3419 * @deprecated Use getFavorites(String id) instead
3421 public List
<Status
> favorites(String id
) throws WeiboException
{
3422 return getFavorites(id
);
3427 * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
3429 * @param id the ID or screen name of the user for whom to request a list of favorite statuses
3430 * @param page the number of page
3431 * @return List<Status>
3432 * @throws WeiboException when Weibo service or network is unavailable
3433 * @deprecated Use getFavorites(String id, int page) instead
3434 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites">favorites </a>
3436 public List
<Status
> favorites(String id
, int page
) throws WeiboException
{
3437 return getFavorites(id
, page
);
3442 * Enables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.
3446 * @throws WeiboException when Weibo service or network is unavailable
3447 * @deprecated Use enableNotification(String id) instead
3449 public User
follow(String id
) throws WeiboException
{
3450 return enableNotification(id
);
3455 * Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.
3458 * @throws WeiboException when Weibo service or network is unavailable
3459 * @deprecated Use disableNotification(String id) instead
3461 public User
leave(String id
) throws WeiboException
{
3462 return disableNotification(id
);
3469 * Blocks the user specified in the ID parameter as the authenticating user. Returns the blocked user in the requested format when successful.
3470 * @param id the ID or screen_name of the user to block
3471 * @return the blocked user
3472 * @throws WeiboException when Weibo service or network is unavailable
3473 * @since Weibo4J 1.2.1
3474 * @deprecated Use createBlock(String id) instead
3476 public User
block(String id
) throws WeiboException
{
3477 return new User(http
.post(getBaseURL() + "blocks/create/" + id
+ ".xml", true), this);
3482 * Un-blocks the user specified in the ID parameter as the authenticating user. Returns the un-blocked user in the requested format when successful.
3483 * @param id the ID or screen_name of the user to block
3484 * @return the unblocked user
3485 * @throws WeiboException when Weibo service or network is unavailable
3486 * @since Weibo4J 1.2.1
3487 * @deprecated Use destroyBlock(String id) instead
3489 public User
unblock(String id
) throws WeiboException
{
3490 return new User(http
.post(getBaseURL() + "blocks/destroy/" + id
+ ".xml", true), this);
3495 * Returns extended information of the authenticated user. This information includes design settings, so third party developers can theme their widgets according to a given user's preferences.<br>
3496 * The call Weibo.getAuthenticatedUser() is equivalent to the call:<br>
3497 * weibo.getUserDetail(weibo.getUserId());
3499 * @throws WeiboException when Weibo service or network is unavailable
3500 * @since Weibo4J 1.2.1
3501 * @deprecated Use verifyCredentials() instead
3503 public User
getAuthenticatedUser() throws WeiboException
{
3504 return new User(get(getBaseURL() + "account/verify_credentials.xml", true),this);
3509 * @return the schedule
3510 * @throws WeiboException when Weibo service or network is unavailable
3511 * @since Weibo4J 1.0.4
3512 * @deprecated this method is not supported by the Weibo API anymore
3514 public String
getDowntimeSchedule() throws WeiboException
{
3515 throw new WeiboException(
3516 "this method is not supported by the Weibo API anymore"
3517 , new NoSuchMethodException("this method is not supported by the Weibo API anymore"));
3520 * Returns the top 20 trending topics for each hour in a given day.
3521 * @return the result
3522 * @throws WeiboException when Weibo service or network is unavailable
3523 * @since Weibo4J 1.2.1
3524 * @deprecated user getTreandDaily instead
3526 public List
<Trends
> getDailyTrends() throws WeiboException
{
3527 return Trends
.constructTrendsList(get(searchBaseURL
+ "trends/daily.json", false));
3530 * Returns the top 20 trending topics for each hour in a given day.
3531 * @param date Permits specifying a start date for the report.
3532 * @param excludeHashTags Setting this to true will remove all hashtags from the trends list.
3533 * @return the result
3534 * @throws WeiboException when Weibo service or network is unavailable
3535 * @since Weibo4J 1.2.1
3536 * @deprecated user getTreandDaily instead
3538 public List
<Trends
> getDailyTrends(Date date
, boolean excludeHashTags
) throws WeiboException
{
3539 return Trends
.constructTrendsList(get(searchBaseURL
3540 + "trends/daily.json?date=" + toDateStr(date
)
3541 + (excludeHashTags ?
"&exclude=hashtags" : ""), false));
3546 * Returns the top 30 trending topics for each day in a given week.
3547 * @return the result
3548 * @throws WeiboException when Weibo service or network is unavailable
3549 * @since Weibo4J 1.2.1
3550 * @deprecated use getTrendsWeekly instead
3552 public List
<Trends
> getWeeklyTrends() throws WeiboException
{
3553 return Trends
.constructTrendsList(get(searchBaseURL
3554 + "trends/weekly.json", false));
3558 * Returns the top 30 trending topics for each day in a given week.
3559 * @param date Permits specifying a start date for the report.
3560 * @param excludeHashTags Setting this to true will remove all hashtags from the trends list.
3561 * @return the result
3562 * @throws WeiboException when Weibo service or network is unavailable
3563 * @since Weibo4J 1.2.1
3564 * @deprecated use getTrendsWeekly instead
3566 public List
<Trends
> getWeeklyTrends(Date date
, boolean excludeHashTags
) throws WeiboException
{
3567 return Trends
.constructTrendsList(get(searchBaseURL
3568 + "trends/weekly.json?date=" + toDateStr(date
)
3569 + (excludeHashTags ?
"&exclude=hashtags" : ""), false));
3571 public void setToken(AccessToken accessToken
) {
3572 this.setToken(accessToken
.getToken(), accessToken
.getTokenSecret());
3575 //----------------------------Tags接口 ----------------------------------------
3578 * Return to the list of tags specified user
3581 * @throws WeiboException
3582 * @since Weibo4J 1.2.1
3583 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Tags">Tags </a>
3584 * @deprecated use getTags instead
3586 public List
<Tag
>gettags(String user_id
)throws WeiboException
{
3587 return Tag
.constructTags(http
.get(getBaseURL()+"tags.json?"+"user_id="+user_id
,true));
3591 * @return a list of tags
3592 * @throws WeiboException
3593 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Tags/suggestions">Tags/suggestions </a>
3594 * @deprecated use getSuggestionsTags
3597 public List
<Tag
> getSuggestions()throws WeiboException
{
3598 return Tag
.constructTags(get(getBaseURL()+"tags/suggestions.json",true));
3602 * @return List<Status>
3603 * @throws WeiboException when Weibo service or network is unavailable
3604 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites">favorites </a>
3605 * @since Weibo4J 1.2.1
3608 public List
<Status
> getFavorites() throws WeiboException
{
3609 // return Status.constructStatuses(get(getBaseURL() + "favorites.xml", new PostParameter[0], true), this);
3610 return Status
.constructStatuses(get(getBaseURL() + "favorites.json", new PostParameter
[0], true));
3614 * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
3616 * @param id the ID or screen name of the user for whom to request a list of favorite statuses
3617 * @return List<Status>
3618 * @throws WeiboException when Weibo service or network is unavailable
3619 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites">favorites </a>
3620 * @since Weibo4J 1.2.1
3623 public List
<Status
> getFavorites(String id
) throws WeiboException
{
3624 // return Status.constructStatuses(get(getBaseURL() + "favorites/" + id + ".xml", new PostParameter[0], true), this);
3625 return Status
.constructStatuses(get(getBaseURL() + "favorites/" + id
+ ".json", new PostParameter
[0], true));
3629 * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
3631 * @param id the ID or screen name of the user for whom to request a list of favorite statuses
3632 * @param page the number of page
3633 * @return List<Status>
3634 * @throws WeiboException when Weibo service or network is unavailable
3635 * @since Weibo4J 1.2.1
3636 * @see <a href="http://open.t.sina.com.cn/wiki/index.php/Favorites">favorites </a>
3639 public List
<Status
> getFavorites(String id
, int page
) throws WeiboException
{
3640 // return Status.constructStatuses(get(getBaseURL() + "favorites/" + id + ".xml", "page", String.valueOf(page), true), this);
3641 return Status
.constructStatuses(get(getBaseURL() + "favorites/" + id
+ ".json", "page", String
.valueOf(page
), true));