use of org.aisen.android.network.http.HttpConfig 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", "未登录");
}
use of org.aisen.android.network.http.HttpConfig in project AisenWeiBo by wangdan.
the class SinaSDK method urlShort2Long.
/**
* 将一个或多个短链接还原成原始的长链接
*
* @param shortUrlArr
* @return
* @throws TaskException
*/
public UrlsBean urlShort2Long(String... shortUrlArr) throws TaskException {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < shortUrlArr.length; i++) {
if (shortUrlArr[i] == null)
continue;
if (i > 0) {
sb.append("&");
}
sb.append("url_short").append("=").append(shortUrlArr[i]);
}
HttpConfig config = configHttpConfig();
config.baseUrl = config.baseUrl + "short_url/expand.json?access_token=" + token.getToken() + "&" + sb.toString();
return doGet(config, getSetting("shortUrlExpand"), null, UrlsBean.class);
}
use of org.aisen.android.network.http.HttpConfig in project AisenWeiBo by wangdan.
the class SinaSDK method webGetHotTopicsHotStatus.
/**
* 热门话题的推荐推荐微博列表
*
* @param containerId
* @param sinceId
* @return
* @throws TaskException
*/
public StatusContents webGetHotTopicsHotStatus(String containerId, String sinceId) throws TaskException {
Params params = new Params();
params.addParameter("containerid", containerId);
if (!TextUtils.isEmpty(sinceId)) {
params.addParameter("since_id", sinceId);
}
Setting action = newSetting("webGetHotTopicsHotStatus", "container/getIndex", "热门话题热门微博");
action.getExtras().put(HTTP_UTILITY, newSettingExtra(HTTP_UTILITY, TimelineHotTopicsHttpUtility.class.getName(), ""));
HttpConfig config = webConfig();
config.addHeader("Referer", String.format("http://m.weibo.cn/p/index?containerid=%s", containerId));
try {
return doGet(config, action, params, StatusContents.class);
} catch (Exception e) {
if (e instanceof TaskException)
checkWebResult((TaskException) e);
throw e;
}
}
Aggregations