Muitas comunicações? mantenha tudo simples
1
of 3
1
of 4
package example;
import com.sinch.xms.ApiConnection;
import com.sinch.xms.SinchSMSApi;
import com.sinch.xms.api.GroupResult;
import com.sinch.xms.api.MtBatchTextSmsResult;
public class Example {
private static final String SERVICE_PLAN_ID = "SERVICE_PLAN_ID";
private static final String TOKEN = "SERVICE_TOKEN";
private static final String[] RECIPIENTS = {"1232323131", "3213123"};
private static final String SENDER = "SENDER";
public static void main(String[] args) {
try (ApiConnection conn =
ApiConnection.builder().servicePlanId(SERVICE_PLAN_ID).token(TOKEN).start()) {
// Sending a simple Text Message
MtBatchTextSmsResult batch =
conn.createBatch(
SinchSMSApi.batchTextSms()
.sender(SENDER)
.addRecipient(RECIPIENTS)
.body("Something good")
.build());
System.out.println("Successfully sent batch " + batch.id());
// Creating simple Group
GroupResult group = conn.createGroup(SinchSMSApi.groupCreate().name("Subscriber").build());
// Adding members (numbers) into the group
conn.updateGroup(
group.id(), SinchSMSApi.groupUpdate().addMemberInsertion("15418888", "323232").build());
// Sending a message to the group
batch =
conn.createBatch(
SinchSMSApi.batchTextSms()
.addRecipient(group.id().toString())
.body("Something good")
.build());
System.out.println("Successfully sent batch " + batch.id());
} catch (Exception e) {
System.out.println("Batch send failed: " + e.getMessage());
}
}
}
import clx.xms
import requests
client = clx.xms.Client(service_plan_id='{spid}', token='{token}')
create = clx.xms.api.MtBatchTextSmsCreate()
create.sender = '12345'
create.recipients = {'46123123123'}
create.body = 'Hello, world!'
try:
batch = client.create_batch(create)
except (requests.exceptions.RequestException,
clx.xms.exceptions.ApiException) as ex:
print('Failed to communicate with XMS: %s' % str(ex))
$client = new Clx\Xms\Client('{spid}', '{token}');
$batchParams = new \Clx\Xms\Api\MtBatchTextSmsCreate();
$batchParams->setSender('12345');
$batchParams->setRecipients(['46123123123']);
$batchParams->setBody('Hello, World!');
try {
$result = $client->createTextBatch($batchParams);
echo('Successfully sent batch ' . $result->getBatchId());
} catch (\Clx\Xms\ApiException $ex) {
echo('Failed to communicate with XMS: ' . $ex->getMessage() . "\n");
}