Search in sources :

Example 11 with HttpConfig

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", "未登录");
}
Also used : LikeResultBean(org.aisen.weibo.sina.support.bean.LikeResultBean) TaskException(org.aisen.android.network.task.TaskException) Setting(org.aisen.android.common.setting.Setting) Params(org.aisen.android.network.http.Params) HttpConfig(org.aisen.android.network.http.HttpConfig)

Example 12 with HttpConfig

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);
}
Also used : HttpConfig(org.aisen.android.network.http.HttpConfig)

Example 13 with HttpConfig

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;
    }
}
Also used : TaskException(org.aisen.android.network.task.TaskException) Setting(org.aisen.android.common.setting.Setting) Params(org.aisen.android.network.http.Params) HttpConfig(org.aisen.android.network.http.HttpConfig) ParseException(java.text.ParseException) TaskException(org.aisen.android.network.task.TaskException)

Aggregations

HttpConfig (org.aisen.android.network.http.HttpConfig)13 Params (org.aisen.android.network.http.Params)8 TaskException (org.aisen.android.network.task.TaskException)8 Setting (org.aisen.android.common.setting.Setting)7 JSONObject (com.alibaba.fastjson.JSONObject)3 ParseException (java.text.ParseException)3 JSONArray (com.alibaba.fastjson.JSONArray)2 ArrayList (java.util.ArrayList)2 LikeResultBean (org.aisen.weibo.sina.support.bean.LikeResultBean)2 ScanResult (android.net.wifi.ScanResult)1 WifiManager (android.net.wifi.WifiManager)1 NeighboringCellInfo (android.telephony.NeighboringCellInfo)1 TelephonyManager (android.telephony.TelephonyManager)1 GsmCellLocation (android.telephony.gsm.GsmCellLocation)1 SpannableString (android.text.SpannableString)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DefHttpUtility (org.aisen.android.network.http.DefHttpUtility)1 SearchsResultUser (org.aisen.weibo.sina.sinasdk.bean.SearchsResultUser)1 SinaLocationMap (org.aisen.weibo.sina.sinasdk.bean.SinaLocationMap)1