PHP code example of rootwork / php-sfax

1. Go to this page and download the library: Download rootwork/php-sfax library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rootwork / php-sfax example snippets



$sfax = new Rootwork\Sfax\Client(
    'https://api.sfaxme.com/api',
    'YOURUSERNAME',
    'YOURAPIKEY',
    'YOURENCRYPTIONKEY',
    'YOURIV'
);


$result = $sfax->sendFax(
    'Malcolm Reynolds',
    '19999999999',
    '/path/to/file.pdf'
);

if ($result->isSuccess) {
    $queueId = $result->SendFaxQueueId;
}


$result = $sfax->sendFaxFromUrl(
    'Malcolm Reynolds', 
    '19999999999',
    Rootwork\Sfax\Client::FORMAT_TIF,
    'https://www.yoursite.com/getFile?token=ABC123&file=12345678.tif'
);


$result = $sfax->receiveInboundFax();

foreach ($result->InboundFaxItems as $fax) {
    $fileData = $sfax->downloadInboundFaxAsPdf($fax->FaxId);
    file_put_contents("/faxes/$fax->FaxId.pdf", $fileData);
}
bash
composer