@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2020### Requirements
2121
2222- PHP 5.3.0 or higher
23- - CURL extension
2423- OpenSSL extension
2524
2625
@@ -151,27 +150,29 @@ $reply = $cb->statuses_update($params);
151150
152151``` php
153152$params = array(
154- 'screen_name' => 'jublonet'
153+ 'status' => 'I love London',
154+ 'lat' => 51.5033,
155+ 'long' => 0.1197
155156);
156- $reply = $cb->users_show ($params);
157+ $reply = $cb->statuses_update ($params);
157158```
158159
159- ### Uploading files to Twitter
160-
161- The array syntax is obligatory:
162-
163160``` php
164161$params = array(
165- 'status' => 'Look at this crazy cat! #lolcats',
166- 'media[]' => '/home/jublonet/lolcats.jpg'
162+ 'screen_name' => 'jublonet'
167163);
168- $reply = $cb->statuses_updateWithMedia ($params);
164+ $reply = $cb->users_show ($params);
169165```
166+ This is the [ resulting tweet] ( https://twitter.com/LarryMcTweet/status/482239971399835648 )
167+ sent with the code above.
168+
169+ ### Uploading media to Twitter
170+
171+ Tweet media can be uploaded in a 2-step process.
172+ ** First** you send each image to Twitter, like this:
170173
171- #### Multiple images
172- can be uploaded in a 2-step process. ** First** you send each image to Twitter, like this:
173174``` php
174- // these files to upload
175+ // these files to upload. You can also just upload 1 image!
175176$media_files = array(
176177 'bird1.jpg', 'bird2.jpg', 'bird3.jpg'
177178);
@@ -187,6 +188,7 @@ foreach ($media_files as $file) {
187188 $media_ids[] = $reply->media_id_string;
188189}
189190```
191+
190192** Second,** you attach the collected media ids for all images to your call
191193to ``` statuses/update ``` , like this:
192194
@@ -202,9 +204,20 @@ $reply = $cb->statuses_update(array(
202204print_r($reply);
203205);
204206```
205- Here is a [ sample tweet] ( https://twitter.com/LarryMcTweet/status/475276535386365952 ) sent with the code above.
206207
207- More [ documentation for tweeting with multiple media] ( https://dev.twitter.com/docs/api/multiple-media-extended-entities ) is available on the Twitter Developer site.
208+ Here is a [ sample tweet] ( https://twitter.com/LarryMcTweet/status/475276535386365952 )
209+ sent with the code above.
210+
211+ More [ documentation for tweeting with media] ( https://dev.twitter.com/rest/public/uploading-media-multiple-photos ) is available on the Twitter Developer site.
212+
213+ #### Remote files
214+
215+ Remote files received from ` http ` and ` https ` servers are supported, too:
216+ ``` php
217+ $reply = $cb->media_upload(array(
218+ 'media' => 'http://www.bing.com/az/hprichbg/rb/BilbaoGuggenheim_EN-US11232447099_1366x768.jpg'
219+ ));
220+ ```
208221
209222### Requests with app-only auth
210223
@@ -259,10 +272,10 @@ The library returns the response HTTP status code, so you can detect rate limits
259272I suggest you to check if the ``` $reply->httpstatus ``` property is ``` 400 ```
260273and check with the Twitter API to find out if you are currently being
261274rate-limited.
262- See the [ Rate Limiting FAQ] ( https://dev.twitter.com/docs/ rate-limiting-faq )
275+ See the [ Rate Limiting FAQ] ( https://dev.twitter.com/rest/public/ rate-limiting )
263276for more information.
264277
265- Unless your return format is JOSN , you will receive rate-limiting details
278+ Unless your return format is JSON , you will receive rate-limiting details
266279in the returned data’s ``` $reply->rate ``` property,
267280if the Twitter API responds with rate-limiting HTTP headers.
268281
@@ -419,7 +432,7 @@ $reply = $cb->oauth_accessToken(array(
419432
420433Are you getting a strange error message? If the user is enrolled in
421434login verification, the server will return a HTTP 401 error with a custom body.
422- If you are using the send_error_codes parameter, you will receive the
435+ If you are using the ``` send_error_codes ``` parameter, you will receive the
423436following error message in the response body:
424437
425438``` xml
@@ -449,11 +462,28 @@ at http://curl.haxx.se/docs/caextract.html.
449462
450463### …set the timeout for requests to the Twitter API?
451464
452- For connecting to Twitter, Codebird uses the cURL library.
465+ For connecting to Twitter, Codebird uses the cURL library, if available .
453466You can specify both the connection timeout and the request timeout,
454467in milliseconds:
455468
456469``` php
457470$cb->setConnectionTimeout(2000);
458471$cb->setTimeout(5000);
459472```
473+
474+ If you don't specify the timeout, codebird uses these values:
475+
476+ - connection time = 3000 ms = 3 s
477+ - timeout = 10000 ms = 10 s
478+
479+ ### …disable cURL?
480+
481+ Codebird automatically detects whether you have the PHP cURL extension enabled.
482+ If not, the library will try to connect to Twitter via socket.
483+ For this to work, the PHP setting ` allow_url_fopen ` must be enabled.
484+
485+ You may also manually disable cURL. Use the following call:
486+
487+ ``` php
488+ $cb->setUseCurl(false);
489+ ```
0 commit comments