当前位置: 首页>>代码示例>>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;未经允许,请勿转载。