Queue a fax for delivery

POST Variables

 

Variable Name Var Type Type Description
action String Required Must be “Queue_Fax”
access_id Integer Required Account Number
access_pwd String Required Password on the user’s account
sCallerID Integer Required Sender’s Fax Number (must be 10 digits)
sSenderEmail String Required Sender’s Email Address
sFaxType String Required “SINGLE” or “BROADCAST”
sToFaxNumber String Required 11 digit number or up to 50 11 digit fax numbers separated by a “|” (pipe)
sResponseFormat String Optional “XML” or “JSON” – Default is JSON
sAccountCode String Optional Internal Reference Number (Maximum of 20 characters)
sRetries Integer Optional Number of times the system is to retry a number if busy or an error is encountered – number from 0 to 6
sCoverPage String Optional If you want to use one of the cover ages on file, specify the cover page you wish
to use: “Basic”, “Standard”, “Company”, or “Personal”To use French cover pages, use: “Basicfr”, “Standardfr”, “Companyfr”, or “Personalfr”If a cover page is not provided then all cover page variables will be ignored.NOTE: If the default cover page on the account is set to “Attachments ONLY” the cover page will
not be created irrespective of this variable
sFaxFromHeader String Optional From: On the Fax Header Line(Maximum of 50 characters)
sCPFromName String Optional Sender’s name on the Cover Page
sCPToName String Optional Recipient’s name on the Cover Page
sCPOrganization String Optional Organiation on the Cover Page
sCPSubject String Optional Subject Line on the Cover Page **
sCPComments String Optional Comments placed in the body of the Cover Page
sFileName_x* String Optional*** Valid File Name – We support in excess of 156 different file types, including .zip. Check out our FAQs here to see a list of supported file types
sFileContent_x* String (Base64 Encoded) Optional*** Base64 encoding of file contents
sNotifyURL String Optional Provide an absolute URL (beginning with https:// or https://) and the SRFax system will
POST back the fax status record when the fax completes. (See below for more details). Maximum of 110 characters allowed
sQueueFaxDate String Optional The date you want to schedule a future fax for. Must be in the format YYYY-MM-DD. Required if using sQueueFaxTime
sQueueFaxTime String Optional The time you want to schedule a future fax for. Must be in the format HH:MM, using 24 hour time (ie, 00:00 – 23:59). Required if using sQueueFaxTime

 

NOTES:

  • *You are able to send an unlimited number of files with their content – simply
    replace the “x” with the number order you wish the files to be faxed in. Please
    ensure that the sFileName_1 has content in sFileContent_1 etc.
  • **The subject line details are saved in the fax record even is a cover page is
    not requested – so the subject can be used for filtering / searching
  • *** sFilename_x and sFileContent_x are both required when submitting files as part of your fax
  • You are able to send a fax with just the cover page details.
  • sQueueFaxDate/sQueueFaxTime must be for a future time. The timezone set on the account will be used when scheduling.

 

Returned Variables (JSON or XML Encoded)

 

Status string “Success” or “Failed”
Result string Queued Fax ID (FaxDetailsID) or Reason for failure

 

 

NOTIFY URL POST Response

If the sNotifyURL is provided in the initial Queue_Fax call, the same variables returned
from Get_Fax_Status will be sent the URL you provide as POST variables. At any
time you are still able to poll the fax status by calling Get_Fax_Status if the sNotifyURL is
missed for any reason. The variables sent are as follows:

 

Variable Name Var Type Size Description
FaxDetailsID Integer Fax Job ID
FileName String 50 Name of the fax file
SentStatus String 15 Status of the fax
AccountCode String 20 Account Code provided when fax was scheduled
DateQueued String Date the fax was queued for delivery
DateSent String Date the fax was sent
ToFaxNumber String 20 Recipient Fax Number
Pages Integer Total number of pages
Duration Integer Call length for transmission
RemoteID String 40 Remote Fax ID
ErrorCode String 75 Error message in the event of a failed fax
Size Integer Size of the file

 

NOTES:

  • You have to setup the URL provided in sNotifyURL so that it can handle a POST of the variables listed above
  • The DateQueued and DateSent variables will reflect your accountds timzone settings
  • The error code will be a string describing the error encountered. There is a wide range of possible errors, the most frequent of which are “No Answer”, “Busy”, and “No Remote Fax”

 

 

Examples

 

PHP using cURL

  1. <?php
  2.    $postVariables = array(
  3.      ‘action’         => ‘Queue_Fax’,
  4.      ‘access_id’      => ‘12345’,
  5.      ‘access_pwd’     => ‘myPassword’,
  6.      ‘sCallerID’      => ‘5551234567’,
  7.      ‘sSenderEmail’   => ‘myfax [at] example [dot] com’,
  8.      ‘sFaxType’       => ‘SINGLE’,
  9.      ‘sToFaxNumber’   => ‘15554567890’,
  10.      ‘sCoverPage’     => ‘Basic’,
  11.      ‘sCPSubject’     => ‘My Test Fax’,
  12.      ‘sCPComments’    => ‘This is my text fax via the SRFax API!’,
  13.      ‘sFileName_1’    => ‘MyFax.txt’,
  14.      ‘sFileContent_1’ => base64_encode(file_get_contents(“Files/MyFax.txt”)),
  15.    );
  16.    $curlDefaults = array(
  17.        CURLOPT_POST           => 1,
  18.        CURLOPT_HEADER         => 0,
  19.        CURLOPT_URL            => “https://secure.srfax.com/SRF_SecWebSvc.php”,
  20.        CURLOPT_FRESH_CONNECT  => 1,
  21.        CURLOPT_RETURNTRANSFER => 1,
  22.        CURLOPT_FORBID_REUSE   => 1,
  23.        CURLOPT_TIMEOUT        => 60,
  24.        CURLOPT_SSL_VERIFYPEER => true,
  25.        CURLOPT_SSL_VERIFYHOST => 2,
  26.        CURLOPT_POSTFIELDS     => http_build_query($postVariables),
  27.    );
  28.    $ch = curl_init();
  29.    curl_setopt_array($ch, $curlDefaults);
  30.    $result = curl_exec($ch);
  31.    if (curl_errno($ch)) {
  32.        echo “Error – “ . curl_error($ch);
  33.    }
  34.    else {
  35.        echo “Result:” . print_r( json_decode($result, true), 1 );
  36.    }
  37. ?>

PHP using SRFax Object

  1. <?php
  2.   require_once (“srFax_class.php”);
  3.   $accountID        = “12345”;
  4.   $accountPassword  = “myPassword”;
  5.   // instantiate object with Account ID and Password
  6.   $srFax = new srFax ( $accountID, $accountPassword );
  7.   //Get file contents for the fax
  8.   $file1Name     = “myFax.txt”;
  9.   $file1Contents = base64_encode(file_get_contents(“Files/$file1Name));
  10.   //Setup required variables
  11.   $senderFaxNumber   = “5551234567”;
  12.   $senderEmail       = “myfax [at] example [dot] com”;
  13.   $receiverFaxNumber = “15554567890”;
  14.   try {
  15.       // attempt to queue a fax
  16.       $srFax->Queue_Fax(array(
  17.         ‘sCallerID’      => $senderFaxNumber,
  18.         ‘sSenderEmail’   => $senderEmail,
  19.         ‘sFaxType’       => ‘SINGLE’,
  20.         ‘sToFaxNumber’   => $receiverFaxNumber,
  21.         ‘sFileName_1’    => $file1Name,
  22.         ‘sFileContent_1’ => $file1Contents,
  23.         ‘sCoverPage’     => ‘Basic’,
  24.         ‘sCPSubject’     => “My Test Fax”,
  25.         ‘sCPComments’    => “This is my text fax via the SRFax API!”
  26.       ));
  27.   }
  28.   catch (Exception $e) { // display error when exception is thrown
  29.       die(“Error: $e);
  30.   }
  31.   if ( $srFax->getRequestStatus () ) {
  32.       echo “Success! Fax Details ID = “ . $srFax->getRequestResponse ();
  33.   } else {
  34.       echo “ERROR: “ . $srFax->getRequestResponse ();
  35.   }
  36. ?>