Search code examples
phpapismssms-gatewaytwilio

Twilio REST API - Server error


I am getting the following error when I try to send a SMS using the Twilio REST API.

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

Code:

require("Services/Twilio.php");

$account_sid = "ACD123456789"; // Your Twilio account sid
$auth_token = "ACD123456789"; // Your Twilio auth token

$client = new Services_Twilio($account_sid, $auth_token);
$message = $client->account->sms_messages->create(
  '+1415599XXXX', // From a Twilio number in your account
  '+1609531XXXX', // Text any number
  "Hello world!"
);

print $message->sid;

Solution

  • Do you have JSON and cURL enabled in your PHP hosting environment? This is what I had to do to get the Twilio PHP helper library working on Joyent's shared servers:

    http://carter.rabasa.com/2012/02/10/getting-json-and-curl-enabled-in-php-on-joyent-shared-servers/

    You can also email [email protected] for support if this doesn't resolve your problem.