PHP PDF Fax Syntax
Tags: sdk
Dec 3, 2018 at 10:56am • 4 replies • 0 likes
fax12879
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.
4 Answers
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!
->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!
0
Here is the response after initiating send fax:
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.
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.
0
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
If these all correct, can you post the entire response and let me know so I can try to replicate the problem.
+ Phong
0
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