Skip to content

Instantly share code, notes, and snippets.

@expressmailing
Created December 27, 2018 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save expressmailing/027e323c4512cd848be254d23cde02e0 to your computer and use it in GitHub Desktop.
Save expressmailing/027e323c4512cd848be254d23cde02e0 to your computer and use it in GitHub Desktop.
<?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