Back to project page Music-Share-Android.
The source code is released under:
GNU General Public License
If you think the Android project Music-Share-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.weibo.sdk.android.api; //from w w w . ja v a2 s. c o m import android.text.TextUtils; import com.weibo.sdk.android.Oauth2AccessToken; import com.weibo.sdk.android.WeiboParameters; import com.weibo.sdk.android.net.RequestListener; /** * ??????????????????????<a href= * "http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2#.E5.BE.AE.E5.8D.9A" * >????????</a> * * @author xiaowei6@staff.sina.com.cn */ public class StatusesAPI extends WeiboAPI { public StatusesAPI(Oauth2AccessToken accessToken) { super(accessToken); } private static final String SERVER_URL_PRIX = API_SERVER + "/statuses"; /** * ??????????? * * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param listener */ public void publicTimeline(int count, int page, boolean base_app, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } request(SERVER_URL_PRIX + "/public_timeline.json", params, HTTPMETHOD_GET, listener); } /** * ??????????????????????????? * * @param since_id * ????????????ID?since_id???????????since_id?????????????0 * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param feature * ????ID?0?????1?????2?????3?????4????????0? * @param trim_user * ????user?????false?????user????true?user?????user_id????false? * @param listener */ public void friendsTimeline(long since_id, long max_id, int count, int page, boolean base_app, FEATURE feature, boolean trim_user, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } params.add("feature", feature.ordinal()); if (trim_user) { params.add("trim_user", 1); } else { params.add("trim_user", 0); } request(SERVER_URL_PRIX + "/friends_timeline.json", params, HTTPMETHOD_GET, listener); } /** * ????????????????????????????ID * * @param since_id * ????????????ID?since_id???????????since_id?????????????0 * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param feature * ????ID?0?????1?????2?????3?????4????????0? * @param listener */ public void friendsTimelineIds(long since_id, long max_id, int count, int page, boolean base_app, FEATURE feature, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } params.add("feature", feature.ordinal()); request(SERVER_URL_PRIX + "/friends_timeline/ids.json", params, HTTPMETHOD_GET, listener); } /** * ??????????????????????????? * * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param feature * ????ID?0?????1?????2?????3?????4????????0? * @param trim_user * ????user?????false?????user????true?user?????user_id????false? * @param listener */ public void homeTimeline(long since_id, long max_id, int count, int page, boolean base_app, FEATURE feature, boolean trim_user, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } params.add("feature", feature.ordinal()); if (trim_user) { params.add("trim_user", 1); } else { params.add("trim_user", 0); } request(SERVER_URL_PRIX + "/home_timeline.json", params, HTTPMETHOD_GET, listener); } /** * ?????????????????????? * * @param uid * ????????ID? * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param feature * ????ID?0?????1?????2?????3?????4????????0? * @param trim_user * ????user?????false?????user????true?user?????user_id????false? * @param listener */ public void userTimeline(long uid, long since_id, long max_id, int count, int page, boolean base_app, FEATURE feature, boolean trim_user, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("uid", uid); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 01); } else { params.add("base_app", 0); } params.add("feature", feature.ordinal()); if (trim_user) { params.add("trim_user", 1); } else { params.add("trim_user", 0); } request(SERVER_URL_PRIX + "/user_timeline.json", params, HTTPMETHOD_GET, listener); } /** * ?????????????????????? * * @param screen_name * ??????????? * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param feature * ????ID?0?????1?????2?????3?????4????????0? * @param trim_user * ????user?????false?????user????true?user?????user_id????false? * @param listener */ public void userTimeline(String screen_name, long since_id, long max_id, int count, int page, boolean base_app, FEATURE feature, boolean trim_user, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("screen_name", screen_name); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } params.add("feature", feature.ordinal()); if (trim_user) { params.add("trim_user", 1); } else { params.add("trim_user", 0); } request(SERVER_URL_PRIX + "/user_timeline.json", params, HTTPMETHOD_GET, listener); } /** * ?????????????????????? * * @param screen_name * ??????????? * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param feature * ????ID?0?????1?????2?????3?????4????????0? * @param trim_user * ????user?????false?????user????true?user?????user_id????false? * @param listener */ public void userTimeline(long since_id, long max_id, int count, int page, boolean base_app, FEATURE feature, boolean trim_user, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } params.add("feature", feature.ordinal()); if (trim_user) { params.add("trim_user", 1); } else { params.add("trim_user", 0); } request(SERVER_URL_PRIX + "/user_timeline.json", params, HTTPMETHOD_GET, listener); } /** * ????????????????ID * * @param uid * ????????ID? * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param feature * ????ID?0?????1?????2?????3?????4????????0? * @param listener */ public void userTimelineIds(long uid, long since_id, long max_id, int count, int page, boolean base_app, FEATURE feature, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("uid", uid); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } params.add("feature", feature.ordinal()); request(SERVER_URL_PRIX + "/user_timeline/ids.json", params, HTTPMETHOD_GET, listener); } /** * ????????????????ID * * @param screen_name * ??????????? * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param feature * ????ID?0?????1?????2?????3?????4????????0? * @param listener */ public void userTimelineIds(String screen_name, long since_id, long max_id, int count, int page, boolean base_app, FEATURE feature, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("screen_name", screen_name); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } params.add("feature", feature.ordinal()); request(SERVER_URL_PRIX + "/user_timeline/ids.json", params, HTTPMETHOD_GET, listener); } /** * ????????????????????? * * @param id * ??????????ID? * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param filter_by_author * ???????0?????1????????2????????0? * @param listener */ public void repostTimeline(long id, long since_id, long max_id, int count, int page, AUTHOR_FILTER filter_by_author, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("id", id); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); params.add("filter_by_author", filter_by_author.ordinal()); request(SERVER_URL_PRIX + "/repost_timeline.json", params, HTTPMETHOD_GET, listener); } /** * ??????????????????????????ID * * @param id * ??????????ID? * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param filter_by_author * ???????0?????1????????2????????0? * @param listener */ public void repostTimelineIds(long id, long since_id, long max_id, int count, int page, AUTHOR_FILTER filter_by_author, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("id", id); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); params.add("filter_by_author", filter_by_author.ordinal()); request(SERVER_URL_PRIX + "/repost_timeline/ids.json", params, HTTPMETHOD_GET, listener); } /** * ?????????????????????? * * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param listener */ public void repostByMe(long since_id, long max_id, int count, int page, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); request(SERVER_URL_PRIX + "/repost_by_me.json", params, HTTPMETHOD_GET, listener); } /** * ??????????????????????????@?????? * * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param filter_by_author * ???????0?????1????????2????????0? * @param filter_by_source * ??????????0?????1???????????2???????????0? * @param filter_by_type * ???????0?????????1????????????0? * @param trim_user * ????user?????false?????user????true?user?????user_id????false? * @param listener */ public void mentions(long since_id, long max_id, int count, int page, AUTHOR_FILTER filter_by_author, SRC_FILTER filter_by_source, TYPE_FILTER filter_by_type, boolean trim_user, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); params.add("filter_by_author", filter_by_author.ordinal()); params.add("filter_by_source", filter_by_source.ordinal()); params.add("filter_by_type", filter_by_type.ordinal()); if (trim_user) { params.add("trim_user", 1); } else { params.add("trim_user", 0); } request(SERVER_URL_PRIX + "/mentions.json", params, HTTPMETHOD_GET, listener); } /** * ????@?????????????ID * * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param filter_by_author * ???????0?????1????????2????????0? * @param filter_by_source * ??????????0?????1???????????2???????????0? * @param filter_by_type * ???????0?????????1????????????0? * @param listener */ public void mentionsIds(long since_id, long max_id, int count, int page, AUTHOR_FILTER filter_by_author, SRC_FILTER filter_by_source, TYPE_FILTER filter_by_type, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); params.add("filter_by_author", filter_by_author.ordinal()); params.add("filter_by_source", filter_by_source.ordinal()); params.add("filter_by_type", filter_by_type.ordinal()); request(SERVER_URL_PRIX + "/mentions/ids.json", params, HTTPMETHOD_GET, listener); } /** * ????????????????????? * * @param since_id * ????????????ID?since_id???????????since_id?????????????0? * @param max_id * ????????????ID??????max_id?????????0? * @param count * ?????????????????50? * @param page * ????????????1? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param feature * ????ID?0?????1?????2?????3?????4????????0? * @param trim_user * ????user?????false?????user????true?user?????user_id????false? * @param listener */ public void bilateralTimeline(long since_id, long max_id, int count, int page, boolean base_app, FEATURE feature, boolean trim_user, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("since_id", since_id); params.add("max_id", max_id); params.add("count", count); params.add("page", page); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } params.add("feature", feature.ordinal()); if (trim_user) { params.add("trim_user", 1); } else { params.add("trim_user", 0); } request(SERVER_URL_PRIX + "/bilateral_timeline.json", params, HTTPMETHOD_GET, listener); } /** * ????????ID???????????????? * * @param id * ????????????ID? * @param listener */ public void show(long id, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("id", id); request(SERVER_URL_PRIX + "/show.json", params, HTTPMETHOD_GET, listener); } /** * ???????????????ID?????MID * * @param ids * ???????????????????ID???????20?? * @param type * ???????1???????2?????3????????1? * @param listener */ public void queryMID(long[] ids, TYPE type, RequestListener listener) { WeiboParameters params = new WeiboParameters(); if (1 == ids.length) { params.add("id", ids[0]); } else { params.add("is_batch", 1); StringBuilder strb = new StringBuilder(); for (long id : ids) { strb.append(id).append(","); } strb.deleteCharAt(strb.length() - 1); params.add("id", strb.toString()); } params.add("type", type.ordinal()); request(SERVER_URL_PRIX + "/querymid.json", params, HTTPMETHOD_GET, listener); } /** * ???????????????MID?????ID,??3z4efAo4lk???MID???????base62?????MID * * @param mids * ???????????????????MID???????20?? * @param type * ???????1???????2?????3????????1? * @param inbox * ?????????MID??????????????0????????1????????0 ? * @param isBase62 * MID?????base62????0??????1??????0? * @param listener */ public void queryID(String[] mids, TYPE type, boolean inbox, boolean isBase62, RequestListener listener) { WeiboParameters params = new WeiboParameters(); if (mids != null) { if (1 == mids.length) { params.add("mid", mids[0]); } else { params.add("is_batch", 1); StringBuilder strb = new StringBuilder(); for (String mid : mids) { strb.append(mid).append(","); } strb.deleteCharAt(strb.length() - 1); params.add("mid", strb.toString()); } } params.add("type", type.ordinal()); if (inbox) { params.add("inbox", 0); } else { params.add("inbox", 1); } if (isBase62) { params.add("isBase62", 0); } else { params.add("isBase62", 1); } request(SERVER_URL_PRIX + "/queryid.json", params, HTTPMETHOD_GET, listener); } /** * ?????????????????????? * * @param count * ????????????????50????20? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param listener */ public void hotRepostDaily(int count, boolean base_app, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("count", count); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } request(SERVER_URL_PRIX + "/hot/repost_daily.json", params, HTTPMETHOD_GET, listener); } /** * ??????????????????????, * * @param count * ????????????????50????20? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param listener */ public void hotRepostWeekly(int count, boolean base_app, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("count", count); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } request(SERVER_URL_PRIX + "/hot/repost_weekly.json", params, HTTPMETHOD_GET, listener); } /** * ???????????????????? * * @param count * ????????????????50????20? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param listener */ public void hotCommentsDaily(int count, boolean base_app, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("count", count); if (base_app) { params.add("base_app", 1); } else { params.add("base_app", 0); } request(SERVER_URL_PRIX + "/hot/comments_daily.json", params, HTTPMETHOD_GET, listener); } /** * ???????????????????? * * @param count * ????????????????50????20? * @param base_app * ??????????????????????false?????????????true??????????????false? * @param listener */ public void hotCommentsWeekly(int count, boolean base_app, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("count", count); if (base_app) { params.add("base_app", 0); } else { params.add("base_app", 1); } request(SERVER_URL_PRIX + "/hot/comments_weekly.json", params, HTTPMETHOD_GET, listener); } /** * ?????????????????????? * * @param ids * ????????????????ID???????100?? * @param listener */ public void count(String[] ids, RequestListener listener) { WeiboParameters params = new WeiboParameters(); StringBuilder strb = new StringBuilder(); for (String id : ids) { strb.append(id).append(","); } strb.deleteCharAt(strb.length() - 1); params.add("ids", strb.toString()); request(SERVER_URL_PRIX + "/count.json", params, HTTPMETHOD_GET, listener); } /** * ???????????? * * @param id * ???????????ID? * @param status * ????????????????140?????????????????????? * @param is_comment * ?????????????????????0??????1?????????????2???????????3????????0 * @param listener */ public void repost(long id, String status, COMMENTS_TYPE is_comment, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("id", id); params.add("status", status); params.add("is_comment", is_comment.ordinal()); request(SERVER_URL_PRIX + "/repost.json", params, HTTPMETHOD_POST, listener); } /** * ????????ID???????? * * @param id * ??????????ID? * @param listener */ public void destroy(long id, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("id", id); request(SERVER_URL_PRIX + "/destroy.json", params, HTTPMETHOD_POST, listener); } /** * ?????????????(???????????????????????) * * @param content * ??????????????????????140???? * @param lat * ????????-90.0?+90.0?+????????0.0? * @param lon * ?????????-180.0?+180.0?+?????????0.0? * @param annotation * ??????JSON??? * @param listener */ public void update(String content, String lat, String lon, String annotation, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("status", content); if (!TextUtils.isEmpty(lon)) { params.add("long", lon); } if (!TextUtils.isEmpty(lat)) { params.add("lat", lat); } if(!TextUtils.isEmpty(annotation)){ params.add("annotations", annotation); } request(SERVER_URL_PRIX + "/update.json", params, HTTPMETHOD_POST, listener); } /** * ???????????????????????????urlencode * * @param content * ??????????????????????140??? * @param file * ????????????JPEG??GIF??PNG????????????5M? * @param lat * ????????-90.0?+90.0?+????????0.0? * @param lon * ?????????-180.0?+180.0?+?????????0.0? * @param listener */ public void upload(String content, String file, String lat, String lon,String annotation, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("status", content); params.add("pic", file); if (!TextUtils.isEmpty(lon)) { params.add("long", lon); } if (!TextUtils.isEmpty(lat)) { params.add("lat", lat); } if(!TextUtils.isEmpty(annotation)){ params.add("annotations", annotation); } request(SERVER_URL_PRIX + "/upload.json", params, HTTPMETHOD_POST, listener); } /** * ??????URL????????????????????????????????????????URLencode * * @param status * ??????????????????????140???? * @param imageUrl * ???URL????????http??? * @param lat * ????????-90.0?+90.0?+????????0.0? * @param lon * ?????????-180.0?+180.0?+?????????0.0? * @param listener */ public void uploadUrlText(String status, String imageUrl, String lat, String lon, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("status", status); params.add("url", imageUrl); if (!TextUtils.isEmpty(lon)) { params.add("long", lon); } if (!TextUtils.isEmpty(lat)) { params.add("lat", lat); } request(SERVER_URL_PRIX + "/upload_url_text.json", params, HTTPMETHOD_POST, listener); } /** * ??????????????????? * * @param type * ?????face???????ani???????cartoon?????????face? * @param language * ?????cnname?????twname????????cnname? * @param listener */ public void emotions(EMOTION_TYPE type, LANGUAGE language, RequestListener listener) { WeiboParameters params = new WeiboParameters(); params.add("type", type.name()); params.add("language", language.name()); request(API_SERVER + "/emotions.json", params, HTTPMETHOD_GET, listener); } }