PHP PDF Fax Syntax

  • 1
  • Question
  • Updated 5 months ago
What is the proper syntax to send a PDF via the PHP SDK?  I tried the demo code and was able to successfully send a fax.  Now I am trying to send a PDF that exists in the root directory of the app and getting RenderingFailed messages.  Here is my code:

$request = $rcsdk->createMultipartBuilder()
'to' => array( array('phoneNumber' => $phone), ), 'faxResolution' => 'High', )) ->add('','attachment1.pdf') ->request('/account/~/extension/~/fax'); $response = $rcsdk->platform()->sendRequest($request); I have also tried with these and received without success ...
The ->add line is the only difference between the demo code and the live code.


  • 200 Points 100 badge 2x thumb
  • frustrated

Posted 5 months ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,066 Points 5k badge 2x thumb
Basically if your app works on sandbox environment, it should work on production as well. Can you double check the location of the attachment, and by any chance you forgot to change the Client ID/Secret for production in your app?

If these all correct, can you post the entire response and let me know so I can try to replicate the problem.

+ Phong
Here is the response after initiating send fax:

stdClass Object
    [uri] =>
    [id] => 566925****
[to] => Array ( [0] => stdClass Object ( [phoneNumber] => ***** [location] => ***** [messageStatus] => Queued ) ) [type] => Fax [creationTime] => 2018-12-03T20:17:52.000Z [readStatus] => Unread [priority] => Normal [attachments] => Array ( [0] => stdClass Object ( [id] => 566925**** [uri] => [type] => RenderedDocument [contentType] => application/pdf ) ) [direction] => Outbound [availability] => Alive [messageStatus] => Queued [faxResolution] => High [faxPageCount] => 0 [lastModifiedTime] => 2018-12-03T20:17:52.792Z [coverIndex] => 7
After a few minutes "messageStatus" is updated to  "SendingFailed"  and "faxErrorCode" is updated to  "RenderingFailed".    

I am using the sandbox credentials to test this.  \

Please confirm this syntax correct:

->add('pdf',[full path to pdf])

If not, what should it be?  The documentation does not specify what the two variables are in the ->add event.

Photo of Tyler Long

Tyler Long, Official Rep

  • 9,456 Points 5k badge 2x thumb
RenderFailed probably means that PDF file is invalid. Could you please try with another pdf file?
I tried it with a different PDF and received the same error.  
It was a syntax issue...

 ->add('Plain Text', 'file.txt') is to be used when you want to create a file and fax.

->add(fopen('[full path to file]', 'r')) is to be used to add an existing file to the fax.

I was able to send both faxes using the fopen method.

Photo of Tyler Long

Tyler Long, Official Rep

  • 9,456 Points 5k badge 2x thumb