You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please can someone explain to me how I can convert this code to work with the new Twilio PHP API version available to download on GitHub (twilio-php-5.0.0-RC7)?
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('twilio/Services/Twilio.php'); // Loads the library
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "";
$token = "";
$client = new Services_Twilio($sid, $token);
$messages = $client->account->messages->getIterator(0, 50, array(
'To' => $_SERVER['QUERY_STRING']
));
foreach ($messages as $message) {
echo "<tr><td class=\"text-center\">" . $message->from . "</td><td class=\"text-center\">" . $message->date_sent . "</td><td class=\"text-center\">" . $message->body . "</td></tr>";
}
?>
There is no longer a twilio/Services/Twilio.php file to include and I can't see anything of a similar name and also the documentation doesn't seem to have been updated with a similar example to the above as far as I can see.
I'm not using Composer
The text was updated successfully, but these errors were encountered:
@alex-jch I'm not sure if there's is a way to use this library without composer, but I think there isn't. Please use composer. A new set of v5.x snippets is coming along and you will be able to see it in the API docs in the next few days incrementally. Take a look here. You can also get more information on how to use the new version here.
This is how your snippet would look in v5.x:
<?php// Get the PHP helper library from twilio.com/docs/php/installrequire_once'/path/to/vendor/autoload.php'; // Loads the libraryuse \Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = newClient($sid, $token);
$messages = $client->account->messages->read(
array("to" => $_SERVER['QUERY_STRING']),
50
);
// Loop over the list of calls and echo a property for each oneforeach($messagesas$message) {
echo "<tr><td class=\"text-center\">" . $message->from . "</td><td class=\"text-center\">" . $message->dateSent->format('Y-m-d H:i:s') . "</td><td class=\"text-center\">" . $message->body . "</td></tr>";
}
It is strongly suggested that you use composer, but you don't have to, the library ships with an autoloader that should allow you to use it standalone.
Download the zip
Take the Twilio folder and drop it into your project
Add this line before using any Twilio classes
require_once'Twilio/autoload.php';
useTwilio\Rest\Client;
$client = newClient(ACCOUNT_SID, AUTH_TOKEN); // assuming these constants exist// Do cool stuff with the client
Please can someone explain to me how I can convert this code to work with the new Twilio PHP API version available to download on GitHub (twilio-php-5.0.0-RC7)?
There is no longer a
twilio/Services/Twilio.php
file to include and I can't see anything of a similar name and also the documentation doesn't seem to have been updated with a similar example to the above as far as I can see.I'm not using Composer
The text was updated successfully, but these errors were encountered: