当前位置: 首页>>代码示例>>Java>>正文


Java OAuthClientRequest.setBody方法代码示例

本文整理汇总了Java中org.apache.oltu.oauth2.client.request.OAuthClientRequest.setBody方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthClientRequest.setBody方法的具体用法?Java OAuthClientRequest.setBody怎么用?Java OAuthClientRequest.setBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.oltu.oauth2.client.request.OAuthClientRequest的用法示例。


在下文中一共展示了OAuthClientRequest.setBody方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: send

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
public void send(Activity activity, String jSONBody) throws OAuthSystemException, OAuthProblemException {
    OAuthClientRequest bearerRequest = new OAuthBearerClientRequest(RUNKEEPER_API_URL + "/fitnessActivities")
            .setAccessToken(accessToken).buildQueryMessage();
    bearerRequest.setBody(jSONBody);
    bearerRequest.setHeader(OAuth.HeaderType.CONTENT_TYPE, NEW_ACTIVITY_CONTENT_TYPE);

    // Seems not to be needed although it's specified here: http://developer.runkeeper.com/healthgraph/example-api-calls
    //bearerRequest.setHeader("accept", "application/vnd.com.runkeeper.FitnessActivity+json");
    //bearerRequest.setHeader("Content-Length", "" + jSONBody.length());

    ConnectivityManager connMgr = (ConnectivityManager)
            activity.getSystemService(activity.getBaseContext().CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    if (networkInfo != null && networkInfo.isConnected()) {
        FetchContent fetcher =  new FetchContent(bearerRequest);
        fetcher.execute(MainActivity.AUTHORIZATION_URL);
    } else { }
}
 
开发者ID:flooose,项目名称:gpxkept,代码行数:20,代码来源:RunKeeperRequest.java

示例2: attachParameters

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
private void attachParameters(OAuthClientRequest request, Map<String, String> parameters)
    throws OAuthSystemException {
  List<NameValuePair> params = new ArrayList<NameValuePair>();
  for (Entry<String, String> item : parameters.entrySet()) {
    params.add(new BasicNameValuePair(item.getKey(), item.getValue()));
  }
  try {
    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, charset);
    Header contentType = entity.getContentType();
    request.addHeader(contentType.getName(), contentType.getValue());
    request.setBody(EntityUtils.toString(entity));
  } catch (IOException ex) {
    throw new OAuthSystemException("attach resource parameters", ex);
  }
}
 
开发者ID:hawkxu,项目名称:shiro-oltu,代码行数:16,代码来源:OAuthResRequester.java


注:本文中的org.apache.oltu.oauth2.client.request.OAuthClientRequest.setBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。