question

Alex Gold avatar image
Alex Gold asked Alex Gold commented

SMS API in PHP without needing to install via composer

Hey all!

I need to get hooked up to the SMS API (via PHP), but step one is installing a SDK via composer.

I'm on shared hosting and the host says I can't do that.

Is there a way to access and use the API solely over cURL or a REST API of some kind? (Especially with an easy to use example in PHP where I could plug in my RingCentral keys, my number, and shoot out a text message to someone?)

Thanks!
Alex

sms and text messaging
1 |3000

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

1 Answer

Phong Vu avatar image
Phong Vu answered Alex Gold commented

I built a light PHP library to authenticate and access RingCentral platform and it is available in my GitHub repos listed below. The libraries also require using the composer to install the "vlucas/phpdotenv" dependency. But you can remove it and don't use the environment.

JWT lib

Code flow lib

12 comments
1 |3000

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

Alex Gold avatar image Alex Gold commented ·

I appreciate the response! I'm very out of my element in terms of server stuff (I really just know straight, basic PHP); so I'm not even sure how to remove that dependency.

If I can just get a plain PHP example that connects via cURL or a REST API for one function (sending a text), then I should be able to adapt that to the others (basically I just need to be able to send texts and read old texts; maybe see old calls as well).

I'm even happy to pay someone to write that simple script as it'd take me forever to derive it from the more complicated "full-feature" packages.

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Alex Gold commented ·

Basically, you open the ringcentral.php file and change the code as follows:

Remove the dependency code

/*
require_once('vendor/autoload.php');

$dotenv = Dotenv\Dotenv::createMutable(__DIR__, '.env');
$dotenv->load();


$env_file = "./environment/";
if ($_ENV['ENVIRONMENT'] == "sandbox"){
  $env_file .= ".env-sandbox";
}else{
  $env_file .= ".env-production";
}

$dotenv = Dotenv\Dotenv::createMutable(__DIR__, $env_file);
$dotenv->load();
*/

Replace these params with the actual values

//$url = $_ENV["RC_SERVER_URL"] . "/restapi/oauth/token";
$url = "https://platform.devtest.ringcentral.com/restapi/oauth/token"; // sandbox environment
$url = "https://platform.ringcentral.com/restapi/oauth/token"; // production environment

//$basic = $_ENV["RC_CLIENT_ID"] .":". $_ENV["RC_CLIENT_SECRET"];
$basic = "YourAppClientId:YouAppClientSecret";

$body = http_build_query(array (
              'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
              'assertion' => "Your  JWT token"
            ));


It's hard for me to help you further if you know just a little about PHP. You may need to know a lot more about PHP programming to build an application.

0 Likes 0 ·
Alex Gold avatar image Alex Gold Phong Vu ♦♦ commented ·

Yeah, I was hoping to side step building an entire application if I really just needed one or two simple features - like with Stripe, I was able to build it into a simple PHP function to charge a card via cURL and then adapt as needed from there and it went well (and then I added other features as needed from there).

I might just hop on Freelancer and see if someone wants $10 or $20 to just build a single PHP function where I just put in my authorization details, a phone number to text to, and a message, and it works. I can adapt it from there, but it just takes a lot more time to strip a more fully featured solution down to the simple bones of what I need.

Assuming that's even possible?

0 Likes 0 ·
Show more comments

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