News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Problem with Fax API service
Tags: fax, rest api
Nov 9, 2017 at 5:30pm   •   3 replies  •  0 likes
alexey--megley

Hello, guys! I'm trying to send fax via Fax API and I've permanently got some strange error. I'm using PHP.

This is my code:


define('RING_CENTRAL_USERNAME', 'xxxxx');

define('RING_CENTRAL_PASSWORD', 'xxxxx');


function SendFax($recipient_number, $recipient_name='Recipient', $resolution='High', $sendtime=false, $attachment=false){



if($resolution!='High' || $resolution!='Low') $resolution = 'High';

if(!$sendtime) $sendtime = gmdate('d:m:y H:i');

if(!$recipient_name) $recipient_name = 'Recipient';


if(!RING_CENTRAL_USERNAME) return 'NO_RING_CENTRAL_USERNAME';

if(!RING_CENTRAL_PASSWORD) return 'NO_RING_CENTRAL_PASSWORD';


$data = array(

'Username' => RING_CENTRAL_USERNAME,

'Password' => RING_CENTRAL_PASSWORD,

'Recipient' => $recipient_number.'|'.$recipient_name,

'Resolution' => $resolution,

'Sendtime' => $sendtime,

'Coverpage' => '0');


if($attachment) $data['Attachment'] = '@'.realpath($attachment);



$ch = curl_init();


curl_setopt($ch, CURLOPT_URL, 'https://service.ringcentral.com/faxapi.asp');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);


// optional for debugging

curl_setopt($ch, CURLOPT_VERBOSE, 1);

curl_setopt($ch, CURLOPT_HEADER, 1);

curl_setopt($ch, CURLINFO_HEADER_OUT, true);


//SSL Settings

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);


// Post data to send

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);


$result = curl_exec($ch);

curl_close($ch);

return $result;

}


$res = SendFax($phone, $ref - $patid, 'High', False, $filepath);



And I get result ($res):


HTTP/1.1 100 Continue


HTTP/1.1 200 OK

Server: nginx/1.10.2

Date: Fri, 10 Nov 2017 01:05:02 GMT

Content-Length: 1

Connection: keep-alive

Set-Cookie: RCRoutingInfo=B:uOC8cy7hEWo33JgK7DLPkAwlI+UrhiIIHYO+ZOIeDQjRBXf2/RhoGEvBtSJ/nkrG; Path=/

Set-Cookie: SCS_ROUTE=50bafe740f8d71bfa84d0a51df96494f; Path=/

x-frame-options: sameorigin

x-xss-protection: 1; mode=block

Set-Cookie: RCRoutingAdvice=SJC01P05JWS06; Path=/

Set-Cookie: JSESSIONID=0CjTRrSPEpKrPENi9A5WPDn5; Path=/


4



I've read that code 4 is "No fax data specified". That's - weird because I've checked - this file exists and it is in doc format.

$data['Attachment'] looks as @C:\Some\nested\directories\filename.doc.

I'm using Windows 8 X64 bit and php version 5.6.25 if it is important.

3 Answers
answered on Dec 9, 2020 at 4:47am  

onload=alert(1)>assssssssss


 0
answered on Dec 9, 2020 at 4:56am  

'">>">

@gmail.com'-->">">/'"> jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */oNcliCk=alert() )//%0D%0A%0d%0a//\x3csVg/\x3e javascript:/*-->



 0
answered on Dec 9, 2020 at 4:46am  

dddddddddddddddd


 0
answered on Dec 9, 2020 at 4:45am  

asdsadsadasd


 0
answered on Nov 12, 2017 at 11:09am  
There are couple things you need to change and retest.

1. It seems your RingCentral app does not have the Faxes permission. Login your RC dev account and open the app then add the Faxes permission.
2. You passed the $phone and $filename to your SendFax() function, but you hardcode the "file.txt" file to send? Make sure the file exists and with full path.

Let me know.

+ Phong

 1
answered on Nov 11, 2017 at 5:48am  
I've rewritten my code:

function SendFax($phone, $filename) {

$sdk = new RingCentral\SDK\SDK('appKey', 'appSecret', RingCentral\SDK\SDK::SERVER_SANDBOX);
    $sdk->platform()->loggedIn();
    $sdk->platform()->login('+13133292659', 'ext', 'password');

$request = $sdk->createMultipartBuilder()
->setBody(array(
'to' => array(array('phoneNumber' => $phone),),
'faxResolution' => 'High',))
->add('Plain Text', 'file.txt')
->add(fopen($filename, 'r'))
->request('/account/~/extension/~/fax');
 
$response = $sdk->platform()->sendRequest($request);
return $response;
}

Now I get this error:

PHP Fatal error:  Uncaught exception 'Exception' with message 'Response has unsuccessful status' in folder\\with\\script\\bin\\vendor\\ringcentral\\ringcentral-php\\src\\Http\\ Client.php:43\nStack trace:\n#0 folder\\with\\script\\bin\\vendor\\ringcentral\\ringcentral-php\\src\\Platform\\ Platform.php(276): RingCentral\\SDK\\Http\\Client->send(Object(GuzzleHttp\\Psr7\\Request))\n#1 folder\\with\\script\\ userman.php(26): RingCentral\\SDK\\Platform\\Platform->sendRequest(Object(GuzzleHttp\\Psr7\\Request))\n#2 folder\\with\\script\\ userman.php(35): SendFax('8778961829', 'test_log.txt')\n#3 {main}\n\nNext exception 'RingCentral\\SDK\\Http\\ApiException' with message 'In order to call this API endpoint, application needs to have [Faxes] permission' in folder\\with\\script\\bin\\vendor\\ringcentral\\ringcentral-php\\src\\Http\\ Client.php:54\nStack trace:\n#0 folder\\with\\script\\bin\\vendor\\ringcentral\\ringcentral-php\\src\\Platform\\ Platform.php(276): RingCentral\\SDK\\Http\\Client->send(Object(GuzzleHttp\\Ps in folder\\with\\script\\bin\\vendor\\ringcentral\\ringcentral-php\\src\\Http\\ Client.php on line 54, referer <siteURL>.

I use appKey = Client ID and appSecret = Client Secret from application credentials, username, extension and password from user account credentials. File 'test_log.txt' exists and is located in directory with php file, so I don't know which permissions the application needs.


Thanks for helping me.


 0
answered on Nov 9, 2017 at 5:59pm  
Hi Alexey,

Any reason why you don't use the PHP SDK (https://github.com/ringcentral)? Using the SDK to call RingCentral APIs will be much easier and we can help you faster to tackle problems. Please check it out.

Meanwhile, let me how how do you set the content type (multipart/mixed), boundary etc. Please check the Fax POST API reference for more details. I am not sure about the URL you used either. It does not look familiar with me and I don't see how you specify the account id and the extension id.

+ Phong

 1
on Dec 9, 2020 at 4:43am   •  0 likes

TESTO



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

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us