Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
API audio unitaire exemple push 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>
<add target="+33 178949786" />
// Création d'un socket
$fp = fsockopen('', 80);
if ($fp === false) die("Serveur d'API Express-Mailing non disponible");
// Construction et envoi de la requête HTTP
$request = "POST HTTP/1.0\r\n";
$request .= "Host:\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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment