Fax From PHP4: How to fax a binary file, using NuSOAP
An example of how to send a fax from php of a binary file with PHP4 using NuSOAP
Here's a snippet that shows how to fax an MS Word file. This example applies to any binary file supported by InterFAX, such as PDF or image files. NuSOAP is a one-file download and has no dependencies, making it simpler to install than PEAR::SOAP.
<?php require_once('nusoap.php'); $username = ""; $password = ""; $faxnumber = ""; // formatted like +13055551234, // i.e. +(country code)(area code)(phone number) $file = ""; // binary file to fax $filetype = ""; // e.g. HTML, DOC, PDF, etc.; see // documentation for complete list $postponetime = ""; // e.g. 2001-04-25T20:31:00-04:00, // use a past date/time to fax immediately $resolution = ""; // 0 for standard, 1 for fine $csid = ""; // your fax identifier, visible on // the receiving machine's little screen $subject = ""; // for your reference, visible in the outbound queue $replyemail = ""; // optional address at which to receive an // emailed confirmation // Open File if( !($fp = fopen($file, "r"))) { // Error opening file // Handle error how it is appropriate for your script exit; } // Read data from the file into $data $data = ""; while (!feof($fp)) $data .= fread($fp,1024); $client = new soapclient("http://ws.interfax.net/dfs.asmx?wsdl", true); $params[] = array('Username' => $username, 'Password' => $password, 'FaxNumbers' => $faxnumber, 'FilesData' => base64_encode($data), 'FileTypes' => $filetype, 'FileSizes' => strlen($data), 'Postpone' => $postponetime, 'IsHighResolution' => $resolution, 'CSID' => $csid, 'Subject' => $subject, 'ReplyAddress' => $replyemail ); $result = $client->call("SendfaxEx", $params); echo $result["SendfaxExResult"]; ?>

