Git Product home page Git Product logo

Comments (6)

LingForCC avatar LingForCC commented on September 24, 2024 2

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.

grokify avatar grokify commented on September 24, 2024 1

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.

anilkumarbp avatar anilkumarbp commented on September 24, 2024

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.

numanilyas avatar numanilyas commented on September 24, 2024

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:
php sdk invalid respons string

Regards,
Numan Ilyas

from ringcentral-php.

numanilyas avatar numanilyas commented on September 24, 2024

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.

 avatar commented on September 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.