Search in sources :

Example 6 with JSONObject

use of com.alibaba.fastjson.JSONObject in project ride-read-android by Ride-Read.

the class OkHttpUtils method testInviteCode.

/**
     * 邀请码验证
     * @param inviteCode
     * @param url
     * @return
     */
public Integer testInviteCode(String inviteCode, long timeStamp, String url) {
    try {
        JSONObject json = new JSONObject();
        json.put("code", inviteCode);
        json.put("sign", timeStamp);
        String resp = post(url, json.toString());
        if (resp == null) {
            //归为未知错误
            return null;
        }
        JSONObject jsonObject = JSONObject.parseObject(resp);
        Integer status = jsonObject.getInteger("status");
        return status;
    } catch (JSONException e) {
        return null;
    } catch (Exception e) {
        return null;
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONException(com.alibaba.fastjson.JSONException) JSONException(com.alibaba.fastjson.JSONException) IOException(java.io.IOException)

Example 7 with JSONObject

use of com.alibaba.fastjson.JSONObject in project ride-read-android by Ride-Read.

the class OkHttpUtils method editMessage.

/**
     * 更新基本资料
     * @param url
     * @param
     * @param phone
     * @param birthDate
     * @param sex
     * @param name
     * @param signture
     * @param locale
     * @param school
     * @param job
     * @param hometown
     * @return
     */
public LoginResponse editMessage(String face_url, String phone, String birthDate, int sex, String name, String signture, String locale, String school, String job, String hometown, long timeStamp, String url, int uid, String token, double longtitude, double latitude, List<String> tags) {
    try {
        JSONObject json = new JSONObject();
        json.put("uid", uid);
        json.put("token", token);
        json.put("sign", timeStamp);
        json.put("school", school);
        json.put("location", locale);
        json.put("sex", sex);
        json.put("signature", signture);
        json.put("phonenumber", phone);
        json.put("face_url", face_url);
        json.put("career", job);
        json.put("nickname", name);
        json.put("hometown", hometown);
        json.put("birthday", birthDate);
        json.put("tags", tags);
        json.put("longtitude", longtitude);
        json.put("latitude", latitude);
        String resp = post(url, json.toString());
        if (resp == null) {
            return null;
        }
        return new Gson().fromJson(resp, LoginResponse.class);
    } catch (JSONException e) {
        e.printStackTrace();
        return null;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Gson(com.google.gson.Gson) JSONException(com.alibaba.fastjson.JSONException) JSONException(com.alibaba.fastjson.JSONException) IOException(java.io.IOException)

Example 8 with JSONObject

use of com.alibaba.fastjson.JSONObject in project ride-read-android by Ride-Read.

the class OkHttpUtils method getFollower.

public PersonalInfoFollower getFollower(int uid, String token, long timeStamp, String url) {
    try {
        JSONObject json = new JSONObject();
        json.put("uid", uid);
        json.put("token", token);
        json.put("sign", timeStamp);
        String resp = post(url, json.toString());
        if (resp == null) {
            return null;
        }
        return new Gson().fromJson(resp, PersonalInfoFollower.class);
    } catch (JSONException e) {
        return null;
    } catch (Exception e) {
        return null;
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Gson(com.google.gson.Gson) JSONException(com.alibaba.fastjson.JSONException) JSONException(com.alibaba.fastjson.JSONException) IOException(java.io.IOException)

Example 9 with JSONObject

use of com.alibaba.fastjson.JSONObject in project ride-read-android by Ride-Read.

the class OkHttpUtils method send2BackGround.

/**
     *注册
     * @param userName
     * @param telPhone
     * @param password
     * @param userHeadUrl
     * @param url
     * @return
     */
public LoginResponse send2BackGround(String userName, String telPhone, String password, String userHeadUrl, String url) {
    try {
        JSONObject json = new JSONObject();
        json.put("nickname", userName);
        json.put("face_url", userHeadUrl);
        json.put("phonenumber", telPhone);
        json.put("password", password);
        String resp = post(url, json.toString());
        if (resp == null) {
            return null;
        }
        return new Gson().fromJson(resp, LoginResponse.class);
    } catch (JSONException e) {
        return null;
    } catch (Exception e) {
        return null;
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Gson(com.google.gson.Gson) JSONException(com.alibaba.fastjson.JSONException) JSONException(com.alibaba.fastjson.JSONException) IOException(java.io.IOException)

Example 10 with JSONObject

use of com.alibaba.fastjson.JSONObject in project ride-read-android by Ride-Read.

the class OkHttpUtils method getFollowing.

public PersonalInfoFollowing getFollowing(int uid, String token, long timeStamp, String url) {
    try {
        JSONObject json = new JSONObject();
        json.put("uid", uid);
        json.put("token", token);
        json.put("sign", timeStamp);
        String resp = post(url, json.toString());
        if (resp == null) {
            return null;
        }
        return new Gson().fromJson(resp, PersonalInfoFollowing.class);
    } catch (JSONException e) {
        return null;
    } catch (Exception e) {
        return null;
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Gson(com.google.gson.Gson) JSONException(com.alibaba.fastjson.JSONException) JSONException(com.alibaba.fastjson.JSONException) IOException(java.io.IOException)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)1750 HashMap (java.util.HashMap)302 JSONArray (com.alibaba.fastjson.JSONArray)279 Test (org.junit.Test)217 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)182 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)165 IOException (java.io.IOException)138 ArrayList (java.util.ArrayList)125 Map (java.util.Map)111 AuthPassport (com.ngtesting.platform.util.AuthPassport)96 UserVo (com.ngtesting.platform.vo.UserVo)76 Date (java.util.Date)76 List (java.util.List)72 File (java.io.File)70 UnitResponse (info.xiancloud.core.message.UnitResponse)61 JSONException (com.alibaba.fastjson.JSONException)46 StringEntity (org.apache.http.entity.StringEntity)46 HttpResponse (org.apache.http.HttpResponse)44 Header (org.apache.http.Header)36 DefaultJSONParser (com.alibaba.fastjson.parser.DefaultJSONParser)30