News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
PHP PDF Fax Syntax
Tags: sdk
Dec 3, 2018 at 10:56am   •   4 replies  •  0 likes

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 ...  
->add('pdf','attachment1.pdf')  ->add('application/pdf','attachment1.pdf')

The ->add line is the only difference between the demo code and the live code.

4 Answers
answered on Dec 4, 2018 at 6:41am  
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.


answered on Dec 4, 2018 at 6:18am  
I tried it with a different PDF and received the same error.  

answered on Dec 3, 2018 at 12:40pm  
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.

answered on Dec 3, 2018 at 11:42am  
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


A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

Developer Platform
Integrated Apps
App Gallery
Developer support
Games and rewards

Resource center
Product Releases
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us