8000 Finish 2.6.0 · redaxeprogrammers/codebird-php@07d3e5e · GitHub
[go: up one dir, main page]

Skip to content

Commit 07d3e5e

Browse files
committed
Finish 2.6.0
2 parents 17a1eb1 + 08e59dd commit 07d3e5e

File tree

5 files changed

+746
-376
lines changed

5 files changed

+746
-376
lines changed

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
codebird-php - changelog
22
========================
33

4+
2.6.0 (not yet released)
5+
+ #67 Don't require cURL, allow stream connections too
6+
+ Use default timeout
7+
+ #69 Add composer/installers to allow install path changes
8+
- Regression: Codebird::getApiMethods removed accidentally in 2.5.0
9+
+ #66 Allow remote media uploads
10+
- #81 CURLOPT_TIMEOUT_MS and CURLOPT_CONNECTTIMEOUT_MS errors on PHP 5.3
11+
- #83 Use POST for users/lookup and statuses/lookup, params may get too long for GET
12+
+ Update README to reflect new process for uploading single/multiple media, see #78
13+
414
2.5.0 (2014-06-20)
515
+ Add section about cacert.pem to README
616
+ Option to set cURL timeout

README.md

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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
191193
to ```statuses/update```, like this:
192194

@@ -202,9 +204,20 @@ $reply = $cb->statuses_update(array(
202204
print_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
259272
I suggest you to check if the ```$reply->httpstatus``` property is ```400```
260273
and check with the Twitter API to find out if you are currently being
261274
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)
263276
for 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
266279
in the returned data’s ```$reply->rate``` property,
267280
if the Twitter API responds with rate-limiting HTTP headers.
268281

@@ -419,7 +432,7 @@ $reply = $cb->oauth_accessToken(array(
419432

420433
Are you getting a strange error message? If the user is enrolled in
421434
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
423436
following error message in the response A935 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.
453466
You can specify both the connection timeout and the request timeout,
454467
in 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+
```

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codebird-php",
3-
"version": "2.5.0",
3+
"version": "2.6.0",
44
"homepage": "http://www.jublo.net/projects/codebird/php",
55
"authors": [
66
"Joshua Atkins <joshua.atkins@jublo.net>",

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"networking"
88
],
99
"homepage": "http://www.jublo.net/projects/codebird/php",
10-
"license": "GPL-3.0",
10+
"license": "GPL-3.0+",
1111
"authors": [
1212
{
1313
"name": "Joshua Atkins",
@@ -28,11 +28,10 @@
2828
"source": "https://github.com/jublonet/codebird-php/releases"
2929
},
3030
"require": {
31-
"ext-curl": "*",
3231
"ext-hash": "*",
3332
"ext-json": "*",
3433
"lib-openssl": "*",
35-
"lib-curl": "*"
34+
"composer/installers": "~1.0"
3635
},
3736
"autoload": {
3837
"classmap": ["src/"]

0 commit comments

Comments
 (0)
0