-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RingCentral PHP SDK throwing Uncaught exception InvalidArgumentException on login #29
Comments
You would need to include Composer's autoloader ( https://github.com/ringcentral/ringcentral-php#with-composer-recommended ) within your code to:
Our Demo application within the SDK, uses a {
"appKey": "",
"appSecret": "",
"server": "https://platform.devtest.ringcentral.com",
"username": "1xxxxxxxxxx",
"extension": "",
"password": "",
"fromPhoneNumber": "1xxxxxxxxxx",
"toPhoneNumber": "1xxxxxxxxxx",
"dateFrom": "YYYY-MM-DD",
"dateTo": "YYYY-MM-DD"
} If you do not wish to use the <?php
use RingCentral\SDK\SDK;
use RingCentral\SDK\Http\HttpException;
use RingCentral\http\Response;
require_once(__DIR__ . '/vendor/autoload.php');
try {
$rcsdk = new SDK("sandbox appKey", "sandbox appSecret" , SDK::SERVER_SANDBOX , 'Demo', '1.0.0');
$platform = $rcsdk->platform();
$auth = $platform->login("sandbox number", "extensnion_number", "sandbox password");
// Send SMS
$apiResponse = $platform->post('/account/~/extension/~/sms', array(
'from' => array('phoneNumber'=> '1xxxxxxxxxx'),
'to' => array(
array('phoneNumber' => '1xxxxxxxxxx'),
),
'text' => 'Testing !',
));
print 'Sent SMS ' . $apiResponse->json()->uri . PHP_EOL;
} catch (Exception $e) {
print 'The error is : ' . $e->getMessage() . PHP_EOL;
} |
Another possible problem could be Find the php file named
This is to disable SSL certification verification for cURL library before sending the request. If it is the problem, the reason is that the environment your demo code running on is not associated with a certificate. You could ref this StackOverflow Question for more info. |
Thanks Ling. Setting I have also tried the suggestion mentioned in StackOverflow answer and that also works for me. Regards, |
For posterity, the accepted answer in the Stack Overflow question suggests downloading and installing the trusted CA certificate file from: Then you can set the path to the PEM file in the SDK code or your (1) cURL code This option would require modifying the SDK the Cient.php code as mentioned by @LingForCC. When using this approach, ideally the path parameter could be passed into the SDK. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem"); (2) This option can be used with the PHP SDK as is. curl.cainfo=/path/to/cacert.pem If using the |
RingCentral\SDK\SDK constructor accepts GuzzleHttp\Client as the last argument. The following will work fine for testing and such. $guzzle = new \GuzzleHttp\Client(['verify' => false]);
$sdk = new \RingCentral\SDK\SDK($key, $secret, $server, 'demo', '1.0.0', $guzzle);
$platform = $sdk->platform();
//... |
I am trying to use RingCentral PHP SDK to send SMS. When I use code from demo then I get error shown in below screenshot. When I use JS SDK with same credentials then I am able to successfully send SMS. Following is my code for php:
Please let me know if I am missing something or I need to install any additional component.
The text was updated successfully, but these errors were encountered: