question

er-express-fax541 avatar image
er-express-fax541 asked er-express-fax541 answered

cURL error when Integrating the PHP SDK on my project

Hi,


I am Using RingCentral Connect Platform PHP SDK (https://github.com/ringcentral/ringcentral-php) to send fax messages, I get a curl error when i run the script. I have a developer account and testing the authenticate and Fax message and it works fine.


Error details:

Warning: curl_close(): 28 is not a valid cURL handle resource in <path_to_project>\vendor\ringcentral\ringcentral-php\src\Http\Client.php on line 104    Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Invalid response string' in vendor\ringcentral\psr7\src\functions.php:478  Stack trace:  #0 <path_to_project>\vendor\ringcentral\ringcentral-php\src\Http\ApiResponse.php(56): RingCentral\Psr7\parse_response('HTTP/1.1 0 OK??')  #1 <path_to_project>\vendor\ringcentral\ringcentral-php\src\Http\Client.php(99): RingCentral\SDK\Http\ApiResponse->__construct(Object(RingCentral\Psr7\Request), false, 0)  #2 <path_to_project>\vendor\ringcentral\ringcentral-php\src\Http\Client.php(25): RingCentral\SDK\Http\Client->loadResponse(Object(RingCentral\Psr7\Request))  #3 <path_to_project>\vendor\ringcentral\ringcentral-php\src\Platform\Platform.php(214): RingCentral\SDK\Http\Client->send(Object(RingCentral\Psr7\Request))  #4 <path_to_project>\vendor\ringcentral\ringcentral-php\src\Platform\Platform.php(301): RingCentral\SDK\Platform\Platform->sendReq in C:\inetpub\wwwroot\erexpress\public\vendor\ringcentral\ringcentral-php\src\Http\Client.php on line 44


Sample code (basically the sample code from - https://github.com/ringcentral/ringcentral-php/blob/master/demo/fax.php):


<?php

use RingCentral\SDK\SDK;


require_once(__DIR__.'/vendor/autoload.php');


$credentials = require(__DIR__ . '/vendor/ringcentral/ringcentral-php/demo/_credentials.php');


// Authorize

$platform->login($credentials['username'], $credentials['extension'], $credentials['password']);


// Find Fax-enabled phone number that belongs to extension

$phoneNumbers = $platform->get('/account/~/extension/~/phone-number', array('perPage' => 'max'))

->json()->records;


print 'Fax Phone Number: ' . $credentials['username'] . PHP_EOL;


// Send Fax

$request = $rcsdk->createMultipartBuilder()

->setBody(array(

'to' => array(

array('phoneNumber' => $credentials['username']),

),

'faxResolution' => 'High',

))

->add('Plain Text', 'file.txt')

->add(fopen('https://developers.ringcentral.com/assets/images/ico_case_crm.png', 'r'))

->request('/account/~/extension/~/fax');


//print $request->getBody() . PHP_EOL;


$response = $platform->sendRequest($request);


print 'Sent Fax ' . $response->json()->uri . PHP_EOL;












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.

er-express-fax541 avatar image
er-express-fax541 answered
Hi,

Do we have an option of not displaying the cover page either through the PHP SDK or through the Ringcentral outbound fax settings?
1 |3000

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

ak avatar image
ak answered
You could set the 'coverIndex' parameter as part of the body to 0 (none- no cover page ) for not displaying the cover page when you send a fax. 

Please take a look at our API Explorer to send Fax here :
http://ringcentral.github.io/api-explorer/#!/Messaging/v1_0_account__accountId__extension__extension...
1 |3000

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

er-express-fax541 avatar image
er-express-fax541 answered
Thank you Anil. That worked.
1 |3000

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

er-express-fax541 avatar image
er-express-fax541 answered
Hi, 

Can we remove the header from the fax message :

"From: ER Express Fax Fax: (xxx) xxx xxxx     To:   Fax: +1(xxx) xxx-xxxx Page 1 of 1 12/30/2015"


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