本文整理汇总了Java中com.google.api.client.http.GenericUrl.setHost方法的典型用法代码示例。如果您正苦于以下问题:Java GenericUrl.setHost方法的具体用法?Java GenericUrl.setHost怎么用?Java GenericUrl.setHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.client.http.GenericUrl
的用法示例。
在下文中一共展示了GenericUrl.setHost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildGenericApisUrl
import com.google.api.client.http.GenericUrl; //导入方法依赖的package包/类
public static String buildGenericApisUrl(String domainName, String version, String projectId, String... resourcePathParts) {
GenericUrl genericUrl = new GenericUrl();
genericUrl.setScheme("https");
genericUrl.setHost("www.googleapis.com");
List<String> pathParts = Lists.newArrayList("", domainName, version);
pathParts.add("projects");
pathParts.add(projectId);
if (resourcePathParts != null) {
pathParts.addAll(Lists.newArrayList(resourcePathParts));
}
genericUrl.setPathParts(pathParts);
return genericUrl.build();
}
示例2: getSignature
import com.google.api.client.http.GenericUrl; //导入方法依赖的package包/类
public LinkedHashMap<String, String> getSignature(Map<String, String> options, RequestMethod requestMethod, String endpoint) {
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
OAuthParameters parameters = new OAuthParameters();
parameters.computeTimestamp();
parameters.computeNonce();
parameters.version = "1.0";
parameters.consumerKey = wooCommerce.getWc_key();
GenericUrl genericUrl = new GenericUrl();
genericUrl.setScheme(wooCommerce.isHttps() ? "https" : "http");
genericUrl.setHost(wooCommerce.getBaseUrl());
genericUrl.appendRawPath("/wc-api");
genericUrl.appendRawPath("/v3");
/*
* The endpoint to be called is specified next
* */
genericUrl.appendRawPath(endpoint);
for (Map.Entry<String, String> entry : options.entrySet())
{
System.out.println(entry.getKey() + "/" + entry.getValue());
genericUrl.appendRawPath("/"+entry.getValue());
}
OAuthHmacSigner oAuthHmacSigner = new OAuthHmacSigner();
oAuthHmacSigner.clientSharedSecret = wooCommerce.getWc_secret();
parameters.signer = oAuthHmacSigner;
parameters.signatureMethod = wooCommerce.getSigning_method().getVal();
try {
parameters.computeSignature(requestMethod.getVal(), genericUrl);
} catch (GeneralSecurityException e) {
e.printStackTrace();
}
map.put("oauth_consumer_key", parameters.consumerKey);
map.put("oauth_signature_method", parameters.signatureMethod);
map.put("oauth_timestamp", parameters.timestamp);
map.put("oauth_nonce", parameters.nonce);
map.put("oauth_version", parameters.version);
map.put("oauth_signature", parameters.signature);
genericUrl.put("oauth_consumer_key", parameters.consumerKey);
genericUrl.put("oauth_signature_method", parameters.signatureMethod);
genericUrl.put("oauth_timestamp", parameters.timestamp);
genericUrl.put("oauth_nonce", parameters.nonce);
genericUrl.put("oauth_version", parameters.version);
genericUrl.put("oauth_signature", parameters.signature);
Log.i(TAG,genericUrl.build());
return map;
}