use of com.tencentcloudapi.common.Credential in project tencentcloud-sdk-java by TencentCloud.
the class SignatureTest method testGetTC3HmacSHA256.
@Test
public void testGetTC3HmacSHA256() {
Credential cred = new Credential(System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
HttpProfile httpProfile = new HttpProfile();
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
clientProfile.setSignMethod("TC3-HMAC-SHA256");
httpProfile.setReqMethod("GET");
CvmClient client = new CvmClient(cred, "ap-guangzhou", clientProfile);
DescribeInstancesRequest req = new DescribeInstancesRequest();
try {
DescribeInstancesResponse resp = client.DescribeInstances(req);
Assert.assertTrue(resp.getTotalCount() >= 0);
} catch (TencentCloudSDKException e) {
fail(e.toString());
}
}
use of com.tencentcloudapi.common.Credential in project tencentcloud-sdk-java by TencentCloud.
the class SignatureTest method testPostTC3HmacSHA256.
@Test
public void testPostTC3HmacSHA256() {
Credential cred = new Credential(System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"));
HttpProfile httpProfile = new HttpProfile();
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
clientProfile.setSignMethod("TC3-HMAC-SHA256");
httpProfile.setReqMethod("POST");
CvmClient client = new CvmClient(cred, "ap-guangzhou", clientProfile);
DescribeInstancesRequest req = new DescribeInstancesRequest();
try {
DescribeInstancesResponse resp = client.DescribeInstances(req);
Assert.assertTrue(resp.getTotalCount() >= 0);
} catch (TencentCloudSDKException e) {
fail(e.toString());
}
}
use of com.tencentcloudapi.common.Credential in project tencentcloud-sdk-java-intl-en by TencentCloud.
the class CommonClientCall method main.
public static void main(String[] args) {
try {
Credential cred = new Credential("secretId", "secretKey");
CommonClient client = new CommonClient("cvm", "2017-03-12", cred, "ap-guangzhou");
String resp = client.call("DescribeInstances", "{\"Filters\":" + "[{\"Name\":\"zone\"," + "\"Values\":[\"ap-guangzhou-1\"]}," + "{\"Name\":\"instance-charge-type\"," + "\"Values\":[\"PREPAID\",\"POSTPAID_BY_HOUR\"]}]" + "}");
System.out.println(resp);
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
use of com.tencentcloudapi.common.Credential in project Ant-Live by PinTeh.
the class TencentConfig method getVodClient.
@Bean
public VodClient getVodClient() {
Credential cred = new Credential(iii, kkk);
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("vod.tencentcloudapi.com");
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// Region公共参数,本接口不需要传递此参数。
return new VodClient(cred, "ap-chongqing", clientProfile);
}
use of com.tencentcloudapi.common.Credential in project rhythm by csfwff.
the class VerifycodeMgmtService method sendMsg.
public boolean sendMsg(String[] phoneNumber, String[] templateParam) {
if (Latkes.getRuntimeMode().equals(Latkes.RuntimeMode.DEVELOPMENT)) {
LOGGER.log(Level.INFO, "开发模式不真正发送短信,发送的手机号为:{},当前短信验证码为:{}", phoneNumber, templateParam);
return true;
} else {
Credential cred = new Credential(Symphonys.TEN_SMS_SECRET_ID, Symphonys.TEN_SMS_SECRET_KEY);
SmsClient client = new SmsClient(cred, Symphonys.TEN_SMS_DIYU);
SendSmsRequest req = new SendSmsRequest();
req.setSmsSdkAppId(Symphonys.TEN_SMS_SDK_APPID);
req.setSignName(Symphonys.TEN_SMS_SIGN_NAME);
req.setTemplateId(Symphonys.TEN_SMS_TEMPLATE_ID);
req.setPhoneNumberSet(phoneNumber);
req.setTemplateParamSet(templateParam);
SendSmsResponse res = null;
try {
res = client.SendSms(req);
} catch (TencentCloudSDKException e) {
LOGGER.log(Level.ERROR, "Unable send SMS [phoneNumber={}, templateParam={}]", phoneNumber, templateParam);
return false;
}
assert res != null;
LOGGER.log(Level.INFO, SendSmsResponse.toJsonString(res));
return true;
}
}
Aggregations