In order to use the Voximplant Java SDK, you need the following:
- A developer account. If you don't have one, sign up here.
- A private API key. There are 2 options to obtain it:
- Either generate it in the Voximplant Control panel
- Or call the CreateKey HTTP API method with the specified authentication parameters. You'll receive a response with the result field in it. Save the result value in a file (since we don't store the keys, save it securely on your side).
- JDK 8 and above
Setup a maven
dependency for your project:
<dependency>
<groupId>com.voximplant</groupId>
<artifactId>apiclient</artifactId>
<version>1.10.0</version>
</dependency>
Next, specify the path to the JSON service account file in the constructor.
VoximplantAPIClient api=new VoximplantAPIClient("/path/to/credentials.json");
VoximplantAPIClient api=new VoximplantAPIClient("/path/to/credentials.json");
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
GetCallHistoryResponse callHistory=api.getCallHistory(new GetCallHistoryRequest()
.setFromDate(df.parse("2020-09-01"))
.setToDate(df.parse("2020-10-01"))
.setCount(1));
CallSessionInfoType[]callSessions=callHistory.getResult();
if(callSessions.length==1){
CallSessionInfoType result=callSessions[0];
}
VoximplantAPIClient api=new VoximplantAPIClient("/path/to/credentials.json");
SendSmsMessageResponse sendSmsMessageResponse=api.sendSmsMessage(new SendSmsMessageRequest()
.setSource("447443332211")
.setDestination("447443332212")
.setSmsBody("Test message"));
if(sendSmsMessageResponse.hasResult()){
long result=sendSmsMessageResponse.getResult();
}else{
throw new IllegalArgumentException(sendSmsMessageResponse.getError().getMsg());
}