Question

Fax sent from API but status is Sending failed php


I am trying to Send Fax from PHP SDK it works and providing a sent URL but after that when i check the status of fax it is sending failed.


16 replies

Please provide the sample code and detailed response.
<?php

require_once('_bootstrap.php');

use RingCentralSDKSDK;

// Create SDK instance

$credentials = require('_credentials.php');

$rcsdk = new SDK('', '', 'https://platform.devtest.ringcentral.com', 'app1', '1.0.0');

$platform = $rcsdk->platform();

// Retrieve previous authentication data

$cacheDir = __DIR__ . DIRECTORY_SEPARATOR . '_cache';
$file = $cacheDir . DIRECTORY_SEPARATOR . 'platform.json';

if (!file_exists($cacheDir)) {
    mkdir($cacheDir);
}

$cachedAuth = array();

if (file_exists($file)) {
    $cachedAuth = json_decode(file_get_contents($file), true);
    unlink($file); // dispose cache file, it will be updated if script ends successfully
}

$platform->auth()->setData($cachedAuth);

try {

    $platform->refresh();
$request = $rcsdk->createMultipartBuilder()
                 ->setBody(array(
                     'to'         => array(
                         array('phoneNumber' => '12673314004'),
                     ),
                     'faxResolution' => 'High',
                 ))
                 ->add('Plain Text', 'file.txt')
                 ->add(fopen('D:/wamp/www/vendor/ringcentral/ringcentral-php/demo/file.txt', 'r'))
                 ->request('/account/~/extension/~/fax'); // also has optional $method argument

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

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

} catch (Exception $e) {

    print 'Auth exception: ' . $e->getMessage() . PHP_EOL;

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

    print 'Authorized' . PHP_EOL;

}

// Save authentication data

file_put_contents($file, json_encode($platform->auth()->data(), JSON_PRETTY_PRINT));

Response is 
Sent Fax https://platform.devtest.ringcentral.com/restapi/v1.0/account/198648004/extension/198648004/message-...
Could you please also provide the detailed content of $response = $platform->sendRequest($request);  ?  Are there any exceptions? If so, please post them.

I have to go offline now because it's out of my working hours. We have several Developer Relationship Engineers in different timezones and others will continue to respond.
there is no exception it sent successfully but after Queued it gets failed
i am getting this response while sending Fax.
D:wampwwwvendor2 ingcentral ingcentral-phpdemoauthData.php:58:
object(RingCentralSDKHttpApiResponse)[48]    protected '_jsonAsArray' => null    protected '_jsonAsObject' => null    protected '_multiparts' => null    protected '_response' =>       object(GuzzleHttpPsr7Response)[46]        private 'reasonPhrase' => string 'OK' (length=2)        private 'statusCode' => int 200        private 'headers' =>           array (size=13)            'Server' =>               array (size=1)                ...            'Date' =>               array (size=1)                ...            'Content-Type' =>               array (size=1)                ...            'Content-Length' =>               array (size=1)                ...            'Connection' =>               array (size=1)                ...            'RCRequestId' =>               array (size=1)                ...            'RoutingKey' =>               array (size=1)                ...            'Content-Language' =>               array (size=1)                ...            'Vary' =>               array (size=1)                ...            'X-Rate-Limit-Group' =>               array (size=1)                ...            'X-Rate-Limit-Limit' =>               array (size=1)                ...            'X-Rate-Limit-Remaining' =>               array (size=1)                ...            'X-Rate-Limit-Window' =>               array (size=1)                ...        private 'headerNames' =>           array (size=13)            'server' => string 'Server' (length=6)            'date' => string 'Date' (length=4)            'content-type' => string 'Content-Type' (length=12)            'content-length' => string 'Content-Length' (length=14)            'connection' => string 'Connection' (length=10)            'rcrequestid' => string 'RCRequestId' (length=11)            'routingkey' => string 'RoutingKey' (length=10)            'content-language' => string 'Content-Language' (length=16)            'vary' => string 'Vary' (length=4)            'x-rate-limit-group' => string 'X-Rate-Limit-Group' (length=18)            'x-rate-limit-limit' => string 'X-Rate-Limit-Limit' (length=18)            'x-rate-limit-remaining' => string 'X-Rate-Limit-Remaining' (length=22)            'x-rate-limit-window' => string 'X-Rate-Limit-Window' (length=19)        private 'protocol' => string '1.1' (length=3)        private 'stream' =>           object(GuzzleHttpPsr7Stream)[44]            private 'stream' => resource(66, stream)            private 'size' => null            private 'seekable' => boolean true            private 'readable' => boolean true            private 'writable' => boolean true            private 'uri' => string 'php://temp' (length=10)            private 'customMetadata' =>               array (size=0)                ...    protected '_request' =>       object(GuzzleHttpPsr7Request)[37]        private 'method' => string 'POST' (length=4)        private 'requestTarget' => null        private 'uri' =>           object(GuzzleHttpPsr7Uri)[21]            private 'scheme' => string 'https' (length=5)            private 'userInfo' => string '' (length=0)            private 'host' => string 'platform.devtest.ringcentral.com' (length=32)            private 'port' => null            private 'path' => string '/restapi/v1.0/account/~/extension/~/fax' (length=39)            private 'query' => string '' (length=0)            private 'fragment' => string '' (length=0)        private 'headers' =>           array (size=6)            'Host' =>               array (size=1)                ...            'Content-Type' =>               array (size=1)                ...            'Authorization' =>               array (size=1)                ...            'User-Agent' =>               array (size=1)                ...            'RC-User-Agent' =>               array (size=1)                ...            'Expect' =>               array (size=1)                ...        private 'headerNames' =>           array (size=6)            'content-type' => string 'Content-Type' (length=12)            'authorization' => string 'Authorization' (length=13)            'user-agent' => string 'User-Agent' (length=10)            'rc-user-agent' => string 'RC-User-Agent' (length=13)            'host' => string 'Host' (length=4)            'expect' => string 'Expect' (length=6)        private 'protocol' => string '1.1' (length=3)        private 'stream' =>           object(GuzzleHttpPsr7MultipartStream)[22]            private 'boundary' => string 'de8542ac0534cffa01ee24f9f9d509f1a6770ea3' (length=40)            public 'stream' =>               object(GuzzleHttpPsr7AppendStream)[23
              ...




Every Fax is in Sending failed status after Queued status.
But SMS are sending successfully.
Hi Tayyab,

Your code looks ok and it looks exactly the same as the demo code for PHP SDK.

I just doubt that the number you were trying to sent a fax was the one that cannot receive a fax message (presumed that it was the real number you were sending to!). So I tested sending a fax to that number from my test app and it also failed. Similarly, it failed when I sent a fax to my mobile number. However, the same code would send fax successfully to my RingCentral number or to a real fax number.

Please try again to send fax to a fax machine, or to your other extension number which support fax. You can also try to send to my test number 13129828160

Hope this helps,
Paco
Sent, Please check if you get
i am getting this response when i check it from api explorer of RC
{ "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-...;, "records": [ { "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-...;, "id": 3244561004, "to": [ { "phoneNumber": "+13129828160", "messageStatus": "SendingFailed", "faxErrorCode": "RenderingFailed" } ], "type": "Fax", "creationTime": "2017-07-12T15:29:42.000Z", "readStatus": "Unread", "priority": "Normal", "attachments": [ { "id": 3244561004, "uri": "https://media.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-sto...;, "type": "RenderedDocument", "contentType": "application/pdf" } ], "direction": "Outbound", "availability": "Alive", "messageStatus": "SendingFailed", "faxResolution": "High", "faxPageCount": 0, "lastModifiedTime": "2017-07-12T15:36:51.213Z", "coverIndex": 7 },

I got a test fax from you!

+ Paco
Tayyab,

I used the same exact code and I created a new extension on your sandbox account just to verify on behalf of your account. 

It works fine!  For ref: I have created Ext 102

For more information on how the fax is rendered, you could refer to our FAQ below:

Fax  FAQ RingCentral 

but on my RC windows it is fail....


Can u do a RingCentral Meetings now? I could send in the meeting invite to your email.
yes
Thanks @AK(Anil) for helping.
Now the issue is resolved i was selecting wrong platform.
Now i am using Server No UI and my fax are working fine

Hi,

I am using "Other Non-UI" but still facing the same issue .Initially i am getting successful response with queued status

Message id: 9134754005

Message status: Queued , ,

Message uri to get status- https://platform.devtest.ringcentral.com/restapi/v1.0/account/290219004/extension/290219004/message-store/9134754005

But after some time getting "SendingFailed" status for all sent messages.

I am Using Ringcentral SDK for C# dot net core POC .

@ak -Please suggest the solution


Reply