Skip to main content
The First Step
June 18, 2018
Question

PHP 5.2 Curl Fax Code Examples

So unfortunately I'm stuck on PHP 5.2.3 and cannot upgrade, thus cannot use the official PHP SDK. I need examples of how to set up the FaxOut after obtaining a valid Access Token. Been stuck for the past 3 days.

5 replies

Employee
June 18, 2018
I can show you how to do it with curl. You try to adjust it for PHP curl. 

curl
--header "Accept: application/json"
--header "Authorization: Bearer <token>"
-F "request=@request.json;type=application/json"
-F "attachment=@hello.txt;type=text/plain"
"https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/fax";


Content of request.json file:
{
"to": [{ "phoneNumber": <fax receiver> }]
}


Content of hello.txt:
<Whatever text you want to send.>


You can also send pdf:
-F "attachment=@test.pdf;type=application/pdf"

Employee
June 18, 2018
Been stuck for the past 3 days.
You should have asked for help earlier :)
The First Step
June 18, 2018
But how do I translate that to PHP cURL lib?... such as using curl_init(), curl-setopt(), etc?

Ya, 1.5 days were stuck reading docs and the other 1.5 days were trying to implement things fruitlessly. 
June 18, 2018
Drew,

Try out my PHP "Lite" SDK. It's a 1-file, 0-dependency library designed to support older PHP and uses cURL.

You can see a fax example using the SDK here:

https://github.com/grokify/ringcentral-sdk-php-lite#send-a-fax

You can see the SDK's cURL code here:

https://github.com/grokify/ringcentral-sdk-php-lite/blob/master/src/ringcentrallite.php#L139

I don't have PHP 5.2.3, so let me know if it works for you.
Employee
June 19, 2018
Curl to PHP: https://incarnate.github.io/curl-to-php/

Update: I find that  it doesn't support '-F' at all, so ignore this one.