Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// Création du batch sms (1 contenu + 1 destinataire)
// --------------------------------------------------
$batch = array();
$batch['defaults'] = array("message" => "Hello world !");
$batch['recipients'] = array();
$batch['recipients'][] = array("target" => "0612345678", "countryCode": "FR");
// Préparation de l'appel à l'API Express-Mailing
// ----------------------------------------------
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://batch.express-mailing.com/1.0/sms/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXX"
)
CURLOPT_POSTFIELDS => json_encode()
));
// Envoi du batch et réception de la réponse
// -----------------------------------------
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment