use of org.aisen.android.common.setting.Setting in project AisenWeiBo by wangdan.
the class SinaSDK method statusesMentions.
/**
* 获取最新的提到登录用户的微博列表,即@我的微博
*
* @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
* @return
*/
public StatusContents statusesMentions(Params params) throws TaskException {
Setting action = getSetting("statusesMentions");
action.getExtras().put(HTTP_UTILITY, newSettingExtra(HTTP_UTILITY, TimelineHttpUtility.class.getName(), ""));
return doGet(action, configParams(params), StatusContents.class);
}
use of org.aisen.android.common.setting.Setting in project AisenWeiBo by wangdan.
the class SinaSDK method searchsResultUsers.
/**
* 使用H5页面查询用户
*
* @param q
* @param cookies
* @return
* @throws TaskException
*/
public ArrayList<SearchsResultUser> searchsResultUsers(String q, String cookies) throws TaskException {
ArrayList<SearchsResultUser> resultUsers = new ArrayList<>();
Setting action = newSetting("searchsResultUsers", "page/pageJson", "获取用户");
action.getExtras().put(BASE_URL, newSettingExtra(BASE_URL, "http://m.weibo.cn/", ""));
Params params = new Params();
// params.addParameter("containerid", "100103");
// params.addParameter("type", "3");
// params.addParameter("page", "1");
// params.addParameter("q", q);
// 我也搞不懂这个脑残接口到底怎么玩的
// http://m.weibo.cn/page/pageJson?containerid=100103type%3D3%26q%3Dwang&page=1
params.addParameter("containerid", "100103type%3D3%26q%3D" + q + "&page=1");
try {
HttpConfig config = getHttpConfig();
// config.cookie = cookies;
// config.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
// config.addHeader("Referer", "http://m.weibo.cn/searchs");
String response = doGet(config, action, params, String.class);
JSONObject responseJSON = JSONObject.parseObject(response);
int ok = responseJSON.getInteger("ok");
if (ok == 1) {
JSONArray cardsArray = responseJSON.getJSONArray("cards");
if (cardsArray.size() > 0) {
JSONObject cardGroupsObject = cardsArray.getJSONObject(1);
JSONArray cardGroupArray = cardGroupsObject.getJSONArray("card_group");
for (int i = 0; i < cardGroupArray.size(); i++) {
JSONObject cardGroup = cardGroupArray.getJSONObject(i);
SearchsResultUser user = new SearchsResultUser();
user.setDesc1(cardGroup.getString("desc1"));
user.setDesc2(cardGroup.getString("desc2"));
JSONObject userJSON = cardGroup.getJSONObject("user");
user.setId(userJSON.getString("id"));
user.setFollowing(userJSON.getBoolean("following"));
user.setFollow_me(userJSON.getBoolean("follow_me"));
user.setFansNum(userJSON.getString("fansNum"));
user.setScreen_name(userJSON.getString("screen_name"));
user.setDescription(userJSON.getString("description"));
user.setProfile_image_url(userJSON.getString("profile_image_url"));
user.setStatuses_count(userJSON.getInteger("statuses_count"));
user.setGender(userJSON.getString("gender"));
user.setRemark(userJSON.getString("remark"));
resultUsers.add(user);
}
}
}
} catch (Exception e) {
e.printStackTrace();
if (e instanceof TaskException) {
throw e;
}
}
return resultUsers;
}
use of org.aisen.android.common.setting.Setting in project AisenWeiBo by wangdan.
the class SinaSDK method webGetHotStatuses.
/**
* 热门微博
*
* @param page
* @return
* @throws TaskException
*/
public StatusContents webGetHotStatuses(int page) throws TaskException {
Params params = new Params();
params.addParameter("containerid", "102803");
if (page > 0) {
params.addParameter("since_id", String.valueOf(page));
}
Setting action = newSetting("getHotStatuses", "container/getIndex", "热门微博");
action.getExtras().put(HTTP_UTILITY, newSettingExtra(HTTP_UTILITY, TimelineHotHttpUtility.class.getName(), ""));
return doGet(webConfig(), action, params, StatusContents.class);
}
use of org.aisen.android.common.setting.Setting in project AisenWeiBo by wangdan.
the class SinaSDK method favorites.
/**
* 获取当前登录用户的收藏列表
*
* @param count
* 单页返回的记录条数,默认为50
* @param page
* 返回结果的页码,默认为1
* @param token
* @return
*/
public Favorities favorites(String page, String count) throws TaskException {
Params params = new Params();
params.addParameter("page", page);
if (!TextUtils.isEmpty(count))
params.addParameter("count", count);
else
params.addParameter("count", getPageCount(getSetting("favorites")));
Setting action = getSetting("favorites");
action.getExtras().put(HTTP_UTILITY, newSettingExtra(HTTP_UTILITY, TimelineHttpUtility.class.getName(), ""));
return doGet(action, configParams(params), Favorities.class);
}
use of org.aisen.android.common.setting.Setting in project AisenWeiBo by wangdan.
the class SinaSDK method webCommentLike.
/**
* 评论点赞
*
* @param comment
* @param like
* @return
* @throws TaskException
*/
public LikeResultBean webCommentLike(StatusComment comment, boolean like) throws TaskException {
Params params = new Params();
params.addParameter("id", comment.getLikeId());
params.addParameter("st", "380e9f");
Setting action = newSetting("webCommentLike", like ? "comment/like" : "comment/dislike", "评论点赞");
HttpConfig config = webConfig();
config.addHeader("Referer", String.format("http://m.weibo.cn/status/%s", comment.getStatusId()));
config.addHeader("Content-Type", "application/x-www-form-urlencoded");
config.addHeader("Host", "m.weibo.cn");
config.addHeader("Accept-Language", "zh-CN,en-US;q=0.8");
config.addHeader("Accept", "application/json, text/plain, */*");
String body = doPost(config, action, null, params, null, String.class);
if (!TextUtils.isEmpty(body)) {
Logger.d(TAG, body);
if (body.indexOf("http://passport.weibo.cn/sso/crossdomain") != -1)
throw new TaskException("-100", "未登录");
else if (body.indexOf("<html") != -1)
throw new TaskException("-100", "未登录");
LikeResultBean likeBean = JSON.parseObject(body, LikeResultBean.class);
if (likeBean.getOk() == 1) {
return likeBean;
} else if (likeBean.getOk() == -100) {
throw new TaskException("-100", "未登录");
} else {
throw new TaskException("", likeBean.getMsg());
}
}
throw new TaskException("-100", "未登录");
}
Aggregations