[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 ========================== 2 Frequently Asked Questions 3 ========================== 4 5 Hopefully you can find an answer here to one of your questions. If not, please 6 contact `[email protected] <mailto:[email protected]>`_. 7 8 Debugging Requests 9 ------------------ 10 11 Sometimes the library generates unexpected output. The simplest way to debug is 12 to examine the HTTP request that twilio-php actually sent over the wire. You 13 can turn on debugging with a simple flag: 14 15 .. code-block:: php 16 17 require('Services/Twilio.php'); 18 19 $client = new Services_Twilio('AC123', '456bef'); 20 $client->http->debug = true; 21 22 Then make requests as you normally would. The URI, method, headers, and body 23 of HTTP requests will be logged via the ``error_log`` function. 24 25 26 require: Failed to open stream messages 27 ----------------------------------------- 28 29 If you are trying to use the helper library and you get an error message that 30 looks like this: 31 32 .. code-block:: php 33 34 PHP Warning: require(Services/Twilio.php): failed to open stream: No such 35 file or directory in /path/to/file 36 37 Fatal error: require(): Failed opening required 'Services/Twilio.php' 38 (include_path='.:/usr/lib/php:/usr/local/php-5.3.8/lib/php') in 39 /Library/Python/2.6/site-packages/phpsh/phpsh.php(578): on line 1 40 41 Your PHP file can't find the Twilio library. The easiest way to do this is to 42 move the Services folder from the twilio-php library into the folder containing 43 your file. So if you have a file called ``send-sms.php``, your folder structure 44 should look like this: 45 46 .. code-block:: bash 47 48 . 49 ├── send-sms.php 50 ├── Services 51 │ ├── Twilio.php 52 │ ├── Twilio 53 │ │ ├── ArrayDataProxy.php 54 │ │ ├── (..about 50 other files...) 55 56 If you need to copy all of these files to your web hosting server, the easiest 57 way is to compress them into a ZIP file, copy that to your server with FTP, and 58 then unzip it back into a folder in your CPanel or similar. 59 60 You can also try changing the ``require`` line like this: 61 62 .. code-block:: php 63 64 require('/path/to/twilio-php/Services/Twilio.php'); 65 66 You could also try downloading the library via PEAR, a package manager for PHP, 67 which will add the library to your PHP path, so you can load the Twilio library 68 from anywhere. Run this at the command line: 69 70 .. code-block:: bash 71 72 $ pear channel-discover twilio.github.com/pear 73 $ pear install twilio/Services_Twilio 74 75 If you get the following message: 76 77 .. code-block:: bash 78 79 $ -bash: pear: command not found 80 81 you can install PEAR from their website. 82 83 SSL Validation Exceptions 84 ------------------------- 85 86 If you are using an outdated version of `libcurl`, you may encounter 87 SSL validation exceptions. If you see the following error message, you have 88 a SSL validation exception: :: 89 90 Fatal error: Uncaught exception 'Services_Twilio_TinyHttpException' 91 with message 'SSL certificate problem, verify that the CA cert is OK. 92 93 Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate 94 verify failed' in [MY PATH]\Services\Twilio\TinyHttp.php:89 95 96 This means that Twilio is trying to offer a certificate to verify that you are 97 actually connecting to `https://api.twilio.com <https://api.twilio.com>`_, but 98 your curl client cannot verify our certificate. 99 100 There are four solutions to this problem: 101 102 Upgrade your version of the twilio-php library 103 ============================================== 104 105 Since November 2011, the SSL certificate has been built in to the helper 106 library, and it is used to sign requests made to our API. If you are still 107 encountering this problem, you can upgrade your helper library to the latest 108 version, and you should not encounter this error anymore. 109 110 If you are using an older version of the helper library, you can try one of the 111 following three methods: 112 113 Upgrade your version of libcurl 114 =============================== 115 116 The Twilio certificate is included in the latest version of the 117 ``libcurl`` library. Upgrading your system version of ``libcurl`` will 118 resolve the SSL error. `Click here to download the latest version of 119 libcurl <http://curl.haxx.se/download.html>`_. 120 121 Manually add Twilio's SSL certificate 122 ===================================== 123 124 The PHP curl library can also manually verify an SSL certificate. In your 125 browser, navigate to 126 `https://github.com/twilio/twilio-php/blob/master/Services/cacert.pem 127 <https://github.com/twilio/twilio-php/blob/master/Services/cacert.pem>`_ 128 and download the file. (**Note**: If your browser presents ANY warnings 129 at this time, your Internet connection may be compromised. Do not download the 130 file, and do not proceed with this step). Place this file in the same folder as 131 your PHP script. Then, replace this line in your script: 132 133 .. code-block:: php 134 135 $client = new Services_Twilio($sid, $token); 136 137 with this one: 138 139 .. code-block:: php 140 141 $http = new Services_Twilio_TinyHttp( 142 'https://api.twilio.com', 143 array('curlopts' => array( 144 CURLOPT_SSL_VERIFYPEER => true, 145 CURLOPT_SSL_VERIFYHOST => 2, 146 CURLOPT_CAINFO => getcwd() . "/cacert.pem"))); 147 148 $client = new Services_Twilio($sid, $token, "2010-04-01", $http); 149 150 Disable certificate checking 151 ============================ 152 153 A final option is to disable checking the certificate. Disabling the 154 certificate check means that a malicious third party can pretend to be 155 Twilio, intercept your data, and gain access to your Account SID and 156 Auth Token in the process. Because this is a security vulnerability, 157 we **strongly discourage** you from disabling certificate checking in 158 a production environment. This is known as a `man-in-the-middle attack 159 <http://en.wikipedia.org/wiki/Man-in-the-middle_attack>`_. 160 161 If you still want to proceed, here is code that will disable certificate 162 checking: 163 164 .. code-block:: php 165 166 $http = new Services_Twilio_TinyHttp( 167 'https://api.twilio.com', 168 array('curlopts' => array(CURLOPT_SSL_VERIFYPEER => false)) 169 ); 170 171 $client = new Services_Twilio('AC123', 'token', '2010-04-01', $http); 172 173 If this does not work, double check your Account SID, token, and that you do 174 not have errors anywhere else in your code. If you need further assistance, 175 please email our customer support at `[email protected]`_. 176
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |