本文整理匯總了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;
}