Comments (6)
Another possible problem could be CURLOPT_SSL_VERIFYPEER
is set incorrectly.
Find the php file named ringcentral-php/src/Http/Client.php
in sdk. And add following code at line 73
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
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.
from ringcentral-php.
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 php.ini
file:
(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) php.ini
file
This option can be used with the PHP SDK as is.
curl.cainfo=/path/to/cacert.pem
If using the php.ini
file works, that's great. If there's a reason to need to pass in the path file to the SDK, let us know via this issue or a pull request.
from ringcentral-php.
You would need to include Composer's autoloader ( https://github.com/ringcentral/ringcentral-php#with-composer-recommended ) within your code to:
- Authenticate
- Send SMS
Our Demo application within the SDK, uses a _credentials.json
file to save details like:
{
"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 _credentials.json
file please take a look at the code below:
<?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;
}
from ringcentral-php.
Hi Anil,
Thanks for taking a look. I have installed using composer and you can see in my code I am including autoload:
require(__DIR__ . '/vendor/autoload.php');
I have tried your code and I am still getting same error:
Regards,
Numan Ilyas
from ringcentral-php.
Thanks Ling. Setting CURLOPT_SSL_VERIFYPEER
to false fixed the issue.
I have also tried the suggestion mentioned in StackOverflow answer and that also works for me.
Regards,
Numan Ilyas
from ringcentral-php.
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();
//...
from ringcentral-php.
Related Issues (20)
- PHPOption deprecation warning
- 400 Bad Request (and additional error happened during JSON parse: Response is not JSON)
- FatalError: Unparenthesized `a ? b : c ? d : e` is not supported HOT 2
- php 7.4 Ternary Operator Issue HOT 1
- Undefined array key "code_challenge" HOT 1
- Issue with PHP version 7.4
- telephony webhook end
- Do not specify default "Accept" header HOT 1
- Upgrade PubNub dependency HOT 4
- Root package 'ringcentral/ringcentral-php' cannot require itself in its composer.json
- Required changes for Global Authentication Changes? :question:
- Symfony 7 dependency HOT 1
- Error message truncated in SDK HOT 5
- Unable to pass body in delete request HOT 1
- Symfony/event-dispatcher 5.1.0 not compatible HOT 1
- Whitesource CVE-2020-28032
- Face issue while sending the mms with image.
- trying to filter extension list results in an error with urlencode()
- Client error: `POST https://platform.devtest.ringcentral.com/restapi/oauth/token` resulted in a 400 Bad Request HOT 1
- Composer error: incompatible with guzzlehttp/psr7 2.x+ HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ringcentral-php.