question

fax12879 avatar image
fax12879 asked Tyler Liu commented

PHP PDF Fax Syntax

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()
                 ->setBody(array(
                     '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.

sdk
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered
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
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

fax12879 avatar image
fax12879 answered Tyler Liu commented
Here is the response after initiating send fax:

stdClass Object  (      [uri] => https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/251167004/message-store/~      [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] => https://media.devtest.ringcentral.com/restapi/v1.0/account/251167004/extension/251167004/message-store/5669254004/content/5669254004 [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.





1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

RenderFailed probably means that PDF file is invalid. Could you please try with another pdf file?
0 Likes 0 ·
fax12879 avatar image
fax12879 answered
I tried it with a different PDF and received the same error.  
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

fax12879 avatar image
fax12879 answered Tyler Liu commented
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.

Thanks!
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys