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('dy 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
esteddirectoriesfilename.doc.
I'm using Windows 8 X64 bit and php version 5.6.25 if it is important.