Returns a specified sent or received fax file in PDF or TIFF format

POST Variables

 

Variable Name Var Type Type Description
action String Required Must be “Retrieve_Fax”
access_id Integer Required Account Number
access_pwd String Required Password on the user’s account
sFaxFileName String Required* sFaxFileName returned from Get_Fax_Inbox or Get_Fax_Outbox
sFaxDetailsID Integer Required* sFaxDetailsID of the fax – the ID is located after the “|” (pipe) character of the sFaxFileName
sDirection String Required “IN” or “OUT” for inbound or outbound fax
sSubUserID Integer Optional The account number of a sub account, if you want to use a master account to download a sub account’s fax
sResponseFormat String Optional “XML” or “JSON” – Default is JSON
sFaxFormat String Optional “PDF” or “TIF” – defaults to account settings if not supplied
sMarkasViewed String Optional “Y” – mark fax as viewed once method completes successfully.
“N” or not provided – leave viewed status as is.

 

*NOTE: Either the sFaxFileName or the sFaxDetailsID must be supplied

 

 

Returned Variables (JSON or XML Encoded)

 

Status string “Success” or “Failed”
Result string Base64 encoded fax file contents. The file format will be in PDF or TIF format depending on format requested or the settings selected on your account
Note: If an error is found then the reason for the failure will be in the Result string

 

 

Examples

PHP using cURL

  1. <?php
  2.    $postVariables = array(
  3.      ‘action’         => ‘Retrieve_Fax’,
  4.      ‘access_id’      => ‘12345’,
  5.      ‘access_pwd’     => ‘myPassword’,
  6.      ‘sFaxDetailsID’  => ‘12345678’,
  7.      ‘sDirection’     => ‘OUT’,
  8.    );
  9.    $curlDefaults = array(
  10.        CURLOPT_POST           => 1,
  11.        CURLOPT_HEADER         => 0,
  12.        CURLOPT_URL            => “https://secure.srfax.com/SRF_SecWebSvc.php”,
  13.        CURLOPT_FRESH_CONNECT  => 1,
  14.        CURLOPT_RETURNTRANSFER => 1,
  15.        CURLOPT_FORBID_REUSE   => 1,
  16.        CURLOPT_TIMEOUT        => 60,
  17.        CURLOPT_SSL_VERIFYPEER => false,
  18.        CURLOPT_SSL_VERIFYHOST => 2,
  19.        CURLOPT_POSTFIELDS     => http_build_query($postVariables),
  20.    );
  21.    $ch = curl_init();
  22.    curl_setopt_array($ch, $curlDefaults);
  23.    $result = curl_exec($ch);
  24.    if (curl_errno($ch)) {
  25.        echo “Error – “ . curl_error($ch);
  26.    }
  27.    else {
  28.       echo “Success!”;
  29.       $decodedResult = json_decode($result, 1);
  30.       // save the result to a file
  31.       file_put_contents(“myFax.pdf”, base64_decode($decodedResult[‘Result’]));
  32.    }
  33. ?>

 

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.   try {
  8.       $srFax->Retrieve_Fax(array(
  9.         ‘sFaxDetailsID’ => ‘12345678’,
  10.         ‘sDirection’    => ‘OUT’,
  11.       ));
  12.   }
  13.   catch (Exception $e) { //display error when exception is thrown
  14.       die(“Error: $e);
  15.   }
  16.   if ( $srFax->getRequestStatus () ) {
  17.      echo “Success!”;
  18.      //write file to a file
  19.      $srFax->saveLastResponseAsFile(“myRetrievedFax.pdf”,“../srfax_API_Class/”);
  20.   } else {
  21.       echo “ERROR: “ . $srFax->getRequestResponse ();
  22.   }
  23. ?>