Skip to main content
The First Step
Dec 11, 2015 3:22 PM UTC
Question

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
ingcentral
ingcentral-phpsrcHttpClient.php on line 104    Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Invalid response string' in vendor
ingcentralpsr7srcfunctions.php:478  Stack trace:  #0 <path_to_project>vendor
ingcentral
ingcentral-phpsrcHttpApiResponse.php(56): RingCentralPsr7parse_response('HTTP/1.1 0 OK??')  #1 <path_to_project>vendor
ingcentral
ingcentral-phpsrcHttpClient.php(99): RingCentralSDKHttpApiResponse->__construct(Object(RingCentralPsr7Request), false, 0)  #2 <path_to_project>vendor
ingcentral
ingcentral-phpsrcHttpClient.php(25): RingCentralSDKHttpClient->loadResponse(Object(RingCentralPsr7Request))  #3 <path_to_project>vendor
ingcentral
ingcentral-phpsrcPlatformPlatform.php(214): RingCentralSDKHttpClient->send(Object(RingCentralPsr7Request))  #4 <path_to_project>vendor
ingcentral
ingcentral-phpsrcPlatformPlatform.php(301): RingCentralSDKPlatformPlatform->sendReq in C:inetpubwwwrooterexpresspublicvendor
ingcentral
ingcentral-phpsrcHttpClient.php on line 44


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


<?php

use RingCentralSDKSDK;


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;












14 replies

The First Step
Dec 21, 2015 2:12 PM UTC
Hi,

Do we have an option of not displaying the cover page either through the PHP SDK or through the Ringcentral outbound fax settings?
The First Step
Dec 22, 2015 2:00 AM UTC
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...
The First Step
Dec 22, 2015 6:16 AM UTC
Thank you Anil. That worked.
The First Step
Dec 30, 2015 12:22 PM UTC
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"