當前位置: 首頁>>代碼示例>>Java>>正文


Java FormEncodingBuilder類代碼示例

本文整理匯總了Java中com.squareup.okhttp.FormEncodingBuilder的典型用法代碼示例。如果您正苦於以下問題:Java FormEncodingBuilder類的具體用法?Java FormEncodingBuilder怎麽用?Java FormEncodingBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FormEncodingBuilder類屬於com.squareup.okhttp包,在下文中一共展示了FormEncodingBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doInBackground

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
/**
 *
 * @param params
 * @return
 */
@Override
protected String doInBackground(Void... params) {
    OkHttpClient client = new OkHttpClient();

    HttpUrl httpUrl = HttpUrl.parse(COIN_DESK_API_URL);
    //System.out.println("Requesting : " + httpUrl.toString());

    FormEncodingBuilder formBody = new FormEncodingBuilder();
    formBody.add("lastHours", "24");
    formBody.add("maxRespArrSize", "24");

    Request request = new Request.Builder()
            .url(httpUrl)
            .post(formBody.build())
            .build();

    String content = null;
    try {
        Response response = client.newCall(request).execute();
        ResponseBody body = response.body();

        if (isZipped(response)) {
            content = unzip(body);
        } else {
            content = body.string();
        }

        body.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return content;
}
 
開發者ID:ehanoc,項目名稱:xwallet,代碼行數:40,代碼來源:CexChartAPI.java

示例2: post

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
Call post(Callback callback) throws IOException {
    OkHttpClient client = getUnsafeOkHttpClient();
    CookieManager cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
    client.setCookieHandler(cookieManager);
    RequestBody requestBody = new FormEncodingBuilder()
            .add("user_id", NetId)
            .add("user_password", password)
            .build();
    Request request = new Request.Builder()
            .url("https://studentmaintenance.webapps.snu.edu.in/students/public/studentslist/studentslist/loginauth")
            .post(requestBody)
            .build();
    Call call = client.newCall(request);
    call.enqueue(callback);
    return call;
}
 
開發者ID:anuragsai97,項目名稱:Library-Token-Automation,代碼行數:18,代碼來源:LoginActivity.java

示例3: doInBackground

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
@Override
protected Void doInBackground(Void... params) {

    RequestBody requestBody = new FormEncodingBuilder()
            .add("refresh_token", mRefreshToken)
            .add("client_id", mClientId)
            .add("client_secret", "ADD_YOUR_CLIENT_SECRET")
            .add("grant_type", "refresh_token")
            .build();
    final Request request = new Request.Builder()
            .url(Utils.ACCESS_TOKEN_URL)
            .post(requestBody)
            .build();
    mOkHttpClient.newCall(request).enqueue(new HttpCallback(mCallBack));
    return null;
}
 
開發者ID:NordicSemiconductor,項目名稱:Android-nRF-Beacon-for-Eddystone,代碼行數:17,代碼來源:RefreshAccessTokenTask.java

示例4: doInBackground

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
@Override
protected Void doInBackground(Void... params) {

    RequestBody requestBody = new FormEncodingBuilder()
            .add("grant_type", "authorization_code")
            .add("client_id", mClientId)
            .add("client_secret", "ADD_YOUR_CLIENT_SECRET")
            .add("redirect_uri","")
            .add("code", mCode)
            .build();
    final Request request = new Request.Builder()
            .url(url)
            .post(requestBody)
            .build();
    mOkHttpClient.newCall(request).enqueue(new HttpCallback(mCallBack));
    return null;
}
 
開發者ID:NordicSemiconductor,項目名稱:Android-nRF-Beacon-for-Eddystone,代碼行數:18,代碼來源:RequestAccessTokenTask.java

示例5: buildRequestBody

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
@Override
protected RequestBody buildRequestBody()
{
    RequestBody requestBody = null;
    switch (type)
    {
        case TYPE_PARAMS:
            FormEncodingBuilder builder = new FormEncodingBuilder();
            addParams(builder, params);
            requestBody = builder.build();
            break;
        case TYPE_BYTES:
            requestBody = RequestBody.create(MEDIA_TYPE_STREAM, bytes);
            break;
        case TYPE_FILE:
            requestBody = RequestBody.create(MEDIA_TYPE_STREAM, file);
            break;
        case TYPE_STRING:
            requestBody = RequestBody.create(MEDIA_TYPE_STRING, content);
            break;
    }
    return requestBody;
}
 
開發者ID:dscn,項目名稱:ktball,代碼行數:24,代碼來源:OkHttpPostRequest.java

示例6: addParams

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
private void addParams(FormEncodingBuilder builder, Map<String, String> params)
{
    if (builder == null)
    {
        throw new IllegalArgumentException("builder can not be null .");
    }

    if (params != null && !params.isEmpty())
    {
        for (String key : params.keySet())
        {
            builder.add(key, params.get(key));
            LogUtils.e(key+":"+params.get(key));
        }
    }
}
 
開發者ID:dscn,項目名稱:ktball,代碼行數:17,代碼來源:OkHttpPostRequest.java

示例7: newRequestToken

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
@Override
public Call newRequestToken(String callback) {
    Request req = new Request.Builder()
            .url(provider.requestTokenUrl())
            .method(provider.requestTokenVerb(), new FormEncodingBuilder().build())
            .header("X-OKHttp-OAuth-Authorized", "yes")
            .build();

    OAuthRequest orq = new OAuthRequest(req);
    try {
        OAuthRequest authReq = service.authorizeRequest(orq, consumer, null);

        return okHttpClient.newCall(authReq.authorizedRequest());
    } catch (SigningException e) {
        e.printStackTrace(); // TODO what to do now?!?
    }

    return null;
}
 
開發者ID:dherges,項目名稱:okhttp-oauth,代碼行數:20,代碼來源:OkHttpOAuthClient.java

示例8: newAccessToken

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
@Override
public Call newAccessToken(String verifier) {
    Request req = new Request.Builder()
            .url(provider.requestTokenUrl())
            .method(
                    provider.requestTokenVerb(),
                    new FormEncodingBuilder()
                    .add(OAuth.VERIFIER, verifier)
                    .build()
                )
            .build();

    OAuthRequest orq = new OAuthRequest(req);
    try {
        OAuthRequest authReq = service.authorizeRequest(orq, consumer, null);

        return okHttpClient.newCall(authReq.authorizedRequest());
    } catch (SigningException e) {
        e.printStackTrace(); // TODO what to do now?!?
    }

    return null;
}
 
開發者ID:dherges,項目名稱:okhttp-oauth,代碼行數:24,代碼來源:OkHttpOAuthClient.java

示例9: buildRequestBody

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
@Override
protected RequestBody buildRequestBody()
{
    validParams();
    RequestBody requestBody = null;


    switch (type)
    {
        case TYPE_PARAMS:
            FormEncodingBuilder builder = new FormEncodingBuilder();
            addParams(builder, params);
            requestBody = builder.build();
            break;
        case TYPE_BYTES:
            requestBody = RequestBody.create(mediaType != null ? mediaType : MEDIA_TYPE_STREAM, bytes);
            break;
        case TYPE_FILE:
            requestBody = RequestBody.create(mediaType != null ? mediaType : MEDIA_TYPE_STREAM, file);
            break;
        case TYPE_STRING:
            requestBody = RequestBody.create(mediaType != null ? mediaType : MEDIA_TYPE_STRING, content);
            break;
    }
    return requestBody;
}
 
開發者ID:shegang,項目名稱:meishiDemo,代碼行數:27,代碼來源:OkHttpPostRequest.java

示例10: subscribe

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
@Path("notification/subscribe")
@POST
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public String subscribe(@FormParam(value = "token") String token) throws IOException {
	String url = "https://iid.googleapis.com/iid/v1/" + token + "/rel/topics/" + TOPIC_NAME;
	
	OkHttpClient client = new OkHttpClient();
   	RequestBody body = new FormEncodingBuilder()
               .build();
   	Request request = new Request.Builder()
      .url(url)
      .addHeader("Content-Type", "application/json")
      .addHeader("Authorization", AUTHEN)
      .post(body)
      .build();

	Response response = client.newCall(request).execute();
	

    return String.valueOf(response.code());
}
 
開發者ID:nphau,項目名稱:Angular2-OnlineCinema,代碼行數:22,代碼來源:AccountController.java

示例11: parse

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
@Override
 public void parse() throws IOException {
 	Document doc = Jsoup.connect("http://bhdstar.vn/lich-chieu-theo-phim/").get();	  	
 	Elements elements = doc.select("ul[class=slides bhd-lich-chieu-chon-phim]").get(0).children();
 	
 	for (int i = 0; i < elements.size(); i++) {
 		Film film = FilmManager.searchFilmByName(elements.get(i).select("span[class=movie--name]").text());
 		if (film == null)
 			continue;
  	OkHttpClient client = new OkHttpClient();
  	RequestBody body = new FormEncodingBuilder()
              .add("action", "bhd_lichchieu_chonphim")
              .add("movies_id", elements.get(i).select("a").attr("data-id"))
              .build();
  	Request request = new Request.Builder()
     .url(ajaxUrl)
     .post(body)
     .build();
	
Response response = client.newCall(request).execute();
addShowTimes(response.body().string(), film);


 	}
 }
 
開發者ID:nphau,項目名稱:Angular2-OnlineCinema,代碼行數:26,代碼來源:BHDParser.java

示例12: basePost

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
protected void basePost(String url, Map<String, String> params, CallbackListener<T> listener)
{
    if (params == null) {
       baseGet(url,listener);return;
    }
    FormEncodingBuilder builder = new FormEncodingBuilder();
    Set<Map.Entry<String, String>> entrySet = params.entrySet();
    for (Map.Entry<String, String> entry : entrySet) {
        builder.add(entry.getKey(), entry.getValue());
    }
    RequestBody requestBody = builder.build();
    Request request = new Request.Builder()
            .url(url)
            .post(requestBody)
            .tag(url)
            .build();
    doRequest(request, listener);
}
 
開發者ID:duguju,項目名稱:MousePaintYzz,代碼行數:19,代碼來源:BaseHttp.java

示例13: buildPostFormRequest

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
private Request buildPostFormRequest(String url, Param[] params, Object tag) {
    if (params == null) {
        params = new Param[0];
    }
    FormEncodingBuilder builder = new FormEncodingBuilder();
    for (Param param : params) {
        builder.add(param.key, param.value);
    }
    RequestBody requestBody = builder.build();


    Request.Builder reqBuilder = new Request.Builder();
    reqBuilder.url(url)
            .post(requestBody);

    if (tag != null) {
        reqBuilder.tag(tag);
    }
    return reqBuilder.build();
}
 
開發者ID:pengwei1024,項目名稱:AndroidGeek,代碼行數:21,代碼來源:OkHttpClientManager.java

示例14: insertTOserver

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
public void insertTOserver(final String dt, final String tt, final String ds, final String ts){
    try {
        final String SITE_URL = "http://168.63.175.28/addHistory.php";

        TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        RequestBody formBody = new FormEncodingBuilder()
                .add("isAdd", "true")
                .add("imei", telephonyManager.getDeviceId())
                .add("datestart", dt)
                .add("timestart", tt)
                .add("datestop", ds)
                .add("timestop", ts)
                .build();

        PostForm p= new PostForm(formBody,SITE_URL);
        final Toast toast = Toast.makeText(getApplicationContext(), "เก็บประวัติแล้ว", Toast.LENGTH_SHORT);
        toast.show();
    }
    catch (Exception ex){
        Log.v("ex", ex.toString());
    }
}
 
開發者ID:Popati,項目名稱:Android-BluetoothSPPLibrary-master,代碼行數:23,代碼來源:MainHistory.java

示例15: insertTOserverLocation

import com.squareup.okhttp.FormEncodingBuilder; //導入依賴的package包/類
public void insertTOserverLocation(final String dt, final Double lati, final Double longti){
    try {
        Log.v("insertTOserverLocation", lati + " " + longti);
        TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        final String SITE_URL = "http://168.63.175.28/addLocation.php";

        RequestBody formBody = new FormEncodingBuilder()
                .add("isAdd", "true")
                .add("imei", telephonyManager.getDeviceId())
                .add("time", dt)
                .add("la", Double.toString(lati))
                .add("lo", Double.toString(longti))
                .build();

        PostForm p= new PostForm(formBody,SITE_URL);
        final Toast toast = Toast.makeText(getApplicationContext(), "เก็บตำแหน่งปัจจุบันแล้ว", Toast.LENGTH_SHORT);
        toast.show();
    }
    catch (Exception ex){
        Log.v("ex",ex.toString());
    }
}
 
開發者ID:Popati,項目名稱:Android-BluetoothSPPLibrary-master,代碼行數:23,代碼來源:RSSPullService.java


注:本文中的com.squareup.okhttp.FormEncodingBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。