Skip to content

Instantly share code, notes, and snippets.

@expressmailing
Last active November 23, 2017 13:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save expressmailing/79c42492b0e65c0abc2cb76d34099370 to your computer and use it in GitHub Desktop.
API fax unitaire exemple push PHP
<?php
// Récupération du document en base64
$filename = 'test-fax.doc';
$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="fax" type="on_demand" name="Test API Fax PHP">
<message type="doc">'.$binary.'</message>
<recipients>
<add target="+33 170248254"/>
</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