question

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 asked Boban J edited

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.

sdk
1 |1500 characters needed characters left characters exceeded

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

Tyler Liu avatar image
Tyler Liu answered
Please provide the sample code and detailed response.
1 |1500 characters needed characters left characters exceeded

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

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 answered
<?php

require_once(' _bootstrap.php');

use RingCentral\SDK\SDK;

// 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));

1 |1500 characters needed characters left characters exceeded

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

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 answered
1 |1500 characters needed characters left characters exceeded

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

Tyler Liu avatar image
Tyler Liu answered
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.
1 |1500 characters needed characters left characters exceeded

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

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 answered
there is no exception it sent successfully but after Queued it gets failed
1 |1500 characters needed characters left characters exceeded

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

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 answered
i am getting this response while sending Fax.
D:\wamp\www\vendor2\ringcentral\ringcentral-php\demo\ authData.php:58:
object(RingCentral\SDK\Http\ApiResponse)[48]    protected '_jsonAsArray' => null    protected '_jsonAsObject' => null    protected '_multiparts' => null    protected '_response' =>       object(GuzzleHttp\Psr7\Response)[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(GuzzleHttp\Psr7\Stream)[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(GuzzleHttp\Psr7\Request)[37]        private 'method' => string 'POST' (length=4)        private 'requestTarget' => null        private 'uri' =>           object(GuzzleHttp\Psr7\Uri)[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(GuzzleHttp\Psr7\MultipartStream)[22]            private 'boundary' => string 'de8542ac0534cffa01ee24f9f9d509f1a6770ea3' (length=40)            public 'stream' =>               object(GuzzleHttp\Psr7\AppendStream)[23
              ...




Every Fax is in Sending failed status after Queued status.
But SMS are sending successfully.
1 |1500 characters needed characters left characters exceeded

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

paco-vu avatar image
paco-vu answered
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
1 |1500 characters needed characters left characters exceeded

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

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 answered
Sent, Please check if you get
1 |1500 characters needed characters left characters exceeded

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

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 answered
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 },

1 |1500 characters needed characters left characters exceeded

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

paco-vu avatar image
paco-vu answered tayyab-sajjad6063 commented
I got a test fax from you!

+ Paco
1 comment
1 |1500 characters needed characters left characters exceeded

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

Look i try 3 times to your number but all failed
{ "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": 3244689004, "to": [ { "phoneNumber": "+13129828160", "messageStatus": "SendingFailed", "faxErrorCode": "RenderingFailed" } ], "type": "Fax", "creationTime": "2017-07-12T15:48:15.000Z", "readStatus": "Unread", "priority": "Normal", "attachments": [ { "id": 3244689004, "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:54:53.667Z", "coverIndex": 7 }, { "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 } ], "paging": { "page": 1, "totalPages": 1, "perPage": 100, "totalElements": 2, "pageStart": 0, "pageEnd": 1 }, "navigation": { "firstPage": { "uri": " https://platform.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-...; }, "lastPage": { "uri": " https://platform.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-...; } }
0 Likes 0 ·

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