Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
API audio unitaire exemple push PHP
<?php
// Récupération du document en base64
$filename = 'test-audio.wav';
$binary = fread(fopen($filename, 'r'), filesize($filename));
$binary = base64_encode($binary);
// Création du XML à poster
$xml = '<request login="your-login" password="your-password">
<push media="voice" type="on_demand" name="Test API Audio PHP">
<message type="wav">'.$binary.'</message>
<recipients>
<add target="+33 178949786" />
</recipients>
</push>
</request>';
// Création d'un socket
$fp = fsockopen('api.express-mailing.com', 80);
if ($fp === false) die("Serveur d'API Express-Mailing non disponible");
// Construction et envoi de la requête HTTP
$request = "POST http://api.express-mailing.com/transac/api.ashx HTTP/1.0\r\n";
$request .= "Host: api.express-mailing.com\r\n";
$request .= "Connection: Close\r\n";
$request .= "Content-type: application/x-www-form-urlencoded\r\n";
$request .= "Content-Length: ".strlen($xml)."\r\n";
$request .= "\r\n";
$request .= $xml;
fwrite($fp, $request);
$response = '';
while (!feof($fp))
{
$response .= fgets($fp, 1024);
}
fclose($fp);
die($response);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment