Hopefully you can find an answer here to one of your questions. If not, please contact firstname.lastname@example.org.
If you are trying to use the helper library and you get an error message that looks like this:
PHP Warning: require(Services/Twilio.php): failed to open stream: No such file or directory in /path/to/file Fatal error: require(): Failed opening required 'Services/Twilio.php' (include_path='.:/usr/lib/php:/usr/local/php-5.3.8/lib/php') in /Library/Python/2.6/site-packages/phpsh/phpsh.php(578): on line 1
Your PHP file can't find the Twilio library. The easiest way to do this is to move the Services folder from the twilio-php library into the folder containing your file. So if you have a file called send-sms.php, your folder structure should look like this:
. ├── send-sms.php ├── Services │ ├── Twilio.php │ ├── Twilio │ │ ├── ArrayDataProxy.php │ │ ├── (..about 50 other files...)
If you need to copy all of these files to your web hosting server, the easiest way is to compress them into a ZIP file, copy that to your server with FTP, and then unzip it back into a folder in your CPanel or similar.
You can also try changing the require line like this:
You could also try downloading the library via PEAR, a package manager for PHP, which will add the library to your PHP path, so you can load the Twilio library from anywhere. Run this at the command line:
$ pear channel-discover twilio.github.com/pear $ pear install twilio/Services_Twilio
If you get the following message:
$ -bash: pear: command not found
you can install PEAR from their website.
If you are using an outdated version of libcurl, you may encounter SSL validation exceptions. If you see the following error message, you have a SSL validation exception:
Fatal error: Uncaught exception 'Services_Twilio_TinyHttpException' with message 'SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' in [MY PATH]\Services\Twilio\TinyHttp.php:89
This means that Twilio is trying to offer a certificate to verify that you are actually connecting to https://api.twilio.com, but your curl client cannot verify our certificate.
There are four solutions to this problem:
Since November 2011, the SSL certificate has been built in to the helper library, and it is used to sign requests made to our API. If you are still encountering this problem, you can upgrade your helper library to the latest version, and you should not encounter this error anymore.
If you are using an older version of the helper library, you can try one of the following three methods:
The Twilio certificate is included in the latest version of the libcurl library. Upgrading your system version of libcurl will resolve the SSL error. Click here to download the latest version of libcurl.
The PHP curl library can also manually verify an SSL certificate. In your browser, navigate to https://github.com/twilio/twilio-php/blob/master/Services/twilio_ssl_certificate.crt and download the file. (Note: If your browser presents ANY warnings at this time, your Internet connection may be compromised. Do not download the file, and do not proceed with this step). Place this file in the same folder as your PHP script. Then, replace this line in your script:
$client = new Services_Twilio($sid, $token);
with this one:
$http = new Services_Twilio_TinyHttp( 'https://api.twilio.com', array('curlopts' => array( CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_CAINFO => getcwd() . "/twilio_ssl_certificate.crt"))); $client = new Services_Twilio($sid, $token, "2010-04-01", $http);
A final option is to disable checking the certificate. Disabling the certificate check means that a malicious third party can pretend to be Twilio, intercept your data, and gain access to your Account SID and Auth Token in the process. Because this is a security vulnerability, we strongly discourage you from disabling certificate checking in a production environment. This is known as a man-in-the-middle attack.
If you still want to proceed, here is code that will disable certificate checking:
$http = new Services_Twilio_TinyHttp( 'https://api.twilio.com', array('curlopts' => array(CURLOPT_SSL_VERIFYPEER => false)) ); $client = new Services_Twilio('AC123', 'token', '2010-04-01', $http);
If this does not work, double check your Account SID, token, and that you do not have errors anywhere else in your code. If you need further assistance, please email our customer support at email@example.com.