@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
### Requirements
21
21
22
22
- PHP 5.3.0 or higher
23
- - CURL extension
24
23
- OpenSSL extension
25
24
26
25
@@ -151,27 +150,29 @@ $reply = $cb->statuses_update($params);
151
150
152
151
``` php
153
152
$params = array(
154
- 'screen_name' => 'jublonet'
153
+ 'status' => 'I love London',
154
+ 'lat' => 51.5033,
155
+ 'long' => 0.1197
155
156
);
156
- $reply = $cb->users_show ($params);
157
+ $reply = $cb->statuses_update ($params);
157
158
```
158
159
159
- ### Uploading files to Twitter
160
-
161
- The array syntax is obligatory:
162
-
163
160
``` php
164
161
$params = array(
165
- 'status' => 'Look at this crazy cat! #lolcats',
166
- 'media[]' => '/home/jublonet/lolcats.jpg'
162
+ 'screen_name' => 'jublonet'
167
163
);
168
- $reply = $cb->statuses_updateWithMedia ($params);
164
+ $reply = $cb->users_show ($params);
169
165
```
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:
170
173
171
- #### Multiple images
172
- can be uploaded in a 2-step process. ** First** you send each image to Twitter, like this:
173
174
``` php
174
- // these files to upload
175
+ // these files to upload. You can also just upload 1 image!
175
176
$media_files = array(
176
177
'bird1.jpg', 'bird2.jpg', 'bird3.jpg'
177
178
);
@@ -187,6 +188,7 @@ foreach ($media_files as $file) {
187
188
$media_ids[] = $reply->media_id_string;
188
189
}
189
190
```
191
+
190
192
** Second,** you attach the collected media ids for all images to your call
191
193
to ``` statuses/update ``` , like this:
192
194
@@ -202,9 +204,20 @@ $reply = $cb->statuses_update(array(
202
204
print_r($reply);
203
205
);
204
206
```
205
- Here is a [ sample tweet] ( https://twitter.com/LarryMcTweet/status/475276535386365952 ) sent with the code above.
206
207
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
+ ```
208
221
209
222
### Requests with app-only auth
210
223
@@ -259,10 +272,10 @@ The library returns the response HTTP status code, so you can detect rate limits
259
272
I suggest you to check if the ``` $reply->httpstatus ``` property is ``` 400 ```
260
273
and check with the Twitter API to find out if you are currently being
261
274
rate-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 )
263
276
for more information.
264
277
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
266
279
in the returned data’s ``` $reply->rate ``` property,
267
280
if the Twitter API responds with rate-limiting HTTP headers.
268
281
@@ -419,7 +432,7 @@ $reply = $cb->oauth_accessToken(array(
419
432
420
433
Are you getting a strange error message? If the user is enrolled in
421
434
login 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
423
436
following error message in the response
A935
body:
424
437
425
438
``` xml
@@ -449,11 +462,28 @@ at http://curl.haxx.se/docs/caextract.html.
449
462
450
463
### …set the timeout for requests to the Twitter API?
451
464
452
- For connecting to Twitter, Codebird uses the cURL library.
465
+ For connecting to Twitter, Codebird uses the cURL library, if available .
453
466
You can specify both the connection timeout and the request timeout,
454
467
in milliseconds:
455
468
456
469
``` php
457
470
$cb->setConnectionTimeout(2000);
458
471
$cb->setTimeout(5000);
459
472
```
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