Fatal error: Call to undefined method

  • 1
  • Problem
  • Updated 2 years ago
Hi, I'm having a little dive into the PHP SDK and having followed the guidance on GitHub I'm getting... 

"Fatal error: Call to undefined method RingCentral\SDK\SDK::getPlatform()"

When using: $sdk->getPlatform()->login('USERNAME', 'EXT', 'PASS');

If I use: $sdk->platform()->login('USERNAME', 'EXT', 'PASS');

I get "curl_close(): 52 is not a valid cURL handle resource in phar:"

Any ideas why I can't even validate and login?

Thanks 

James 
Photo of James O'Donnell

James O'Donnell

  • 190 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,642 Points 5k badge 2x thumb
Has your PHP installation been compiled with cURL support?
Photo of James O'Donnell

James O'Donnell

  • 190 Points 100 badge 2x thumb
Yes cURL is working fine, even testing with the following script.


<?php

// Script to test if the CURL extension is installed on this server

// Define function to test
function _is_curl_installed() {
    if  (in_array  ('curl', get_loaded_extensions())) {
        return true;
    }
    else {
        return false;
    }
}

// Ouput text to user based on test
if (_is_curl_installed()) {
  echo "cURL is <span style=\"color:blue\">installed</span> on this server";
} else {
  echo "cURL is NOT <span style=\"color:red\">installed</span> on this server";
}
?>
Gives the following "cURL is installed on this server".

Thanks 

James 
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,642 Points 5k badge 2x thumb
Which version of cURL and PHP are you using please?
Photo of AK

AK, Official Rep

  • 4,382 Points 4k badge 2x thumb
Hi James,

To authenticate the user you should be using :
$sdk->platform()->login('USERNAME', 'EXT', 'PASS');
Do you have composer installed ? If so, have you provided the appropriate path for the composer's autoloader.

For a simpler understanding, take a look at the "develop" branch on our official PHP-SDK repository on github titled "How to Demo" once you have installed the SDK using either composer/PHAR:
https://github.com/ringcentral/ringcentral-php/tree/develop#how-to-demo
Photo of James O'Donnell

James O'Donnell

  • 190 Points 100 badge 2x thumb
Hi PHP version is 5.5.9 cURL is 7.30.0...

I've now got it working, it seems to be a problem with the test server having a self signed certificate, I was using $sdk->getPlatform()->login('USERNAME', 'EXT', 'PASS'); as its what was originally detailed on the github page... 

Thanks 

James 
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,642 Points 5k badge 2x thumb
Yes, I too have had issues with self-signed certificates. If you just need a quick place to test that is not on your local machine, you can use Heroku (they support PHP) since the URL they provide you has a valid certificate chain available. Azure and GCP may also provide this feature, but I've not tested in those environments.