8000 Finish 2.5.0-rc.2 · redaxeprogrammers/codebird-php@deb2a83 · GitHub
[go: up one dir, main page]

Skip to content

Commit deb2a83

Browse files
committed
Finish 2.5.0-rc.2
2 parents 71153b8 + 5cb5abd commit deb2a83

File tree

4 files changed

+128
-123
lines changed

4 files changed

+128
-123
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ codebird-php - changelog
1515
+ Reset bearer token when requesting a new token
1616
+ #61 Return rate limit details with each API call
1717
+ #60 Support uploading multiple media
18+
- #63 Return rate-limiting info only if contained in response
1819

1920
2.4.1 (2013-06-23)
2021
+ #26 Stringify null and boolean parameters

README.md

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ codebird-php
22
============
33
*A Twitter library in PHP.*
44

5-
Copyright (C) 2010-2014 Jublo Solutions <support@jublo.net>
5+
Copyright (C) 2010-2014 Jublo Solutions <support@jublo.net>
66

77
This program is free software: you can redistribute it and/or modify
88
it under the terms of the GNU General Public License as published by
@@ -17,20 +17,15 @@ GNU General Public License for more details.
1717
You should have received a copy of the GNU General Public License
1818
along with this program. If not, see <http://www.gnu.org/licenses/>.
1919

20-
### Versions
21-
22-
- JavaScript: https://github.com/jublonet/codebird-js
23-
- PHP: https://github.com/jublonet/codebird-php
24-
2520
### Requirements
2621

2722
- PHP 5.3.0 or higher
2823
- CURL extension
2924
- OpenSSL extension
3025

3126

32-
1. Authentication
33-
-----------------
27+
Authentication
28+
--------------
3429

3530
To authenticate your API requests on behalf of a certain Twitter user
3631
(following OAuth 1.0a), take a look at these steps:
@@ -92,7 +87,7 @@ if (! isset($_SESSION['oauth_token'])) {
9287
$cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
9388
```
9489

95-
### 1.1. Application-only auth
90+
### Application-only auth
9691

9792
Some API methods also support authenticating on a per-application level.
9893
This is useful for getting data that are not directly related to a specific
@@ -117,8 +112,8 @@ If you already have your token, tell Codebird to use it:
117112
For sending an API request with app-only auth, see the ‘Usage examples’ section.
118113

119114

120-
2. Usage examples
121-
-----------------
115+
Usage examples
116+
--------------
122117

123118
When you have an access token, calling the API is simple:
124119

@@ -206,8 +201,8 @@ $reply = $cb->search_tweets('q=Twitter', true);
206201

207202
Bear in mind that not all API methods support application-only auth.
208203

209-
3. Mapping API methods to Codebird function calls
210-
-------------------------------------------------
204+
Mapping API methods to Codebird function calls
205+
----------------------------------------------
211206

212207
As you can see from the last example, there is a general way how Twitter’s API methods
213208
map to Codebird function calls. The general rules are:
@@ -228,19 +223,19 @@ map to Codebird function calls. The general rules are:
228223
- ```users/profile_image/:screen_name``` maps to
229224
```Codebird::users_profileImage_SCREEN_NAME('screen_name=jublonet')```.
230225

231-
4. HTTP methods (GET, POST, DELETE etc.)
232-
----------------------------------------
226+
HTTP methods (GET, POST, DELETE etc.)
227+
-------------------------------------
233228

234229
Never care about which HTTP method (verb) to use when calling a Twitter API.
235230
Codebird is intelligent enough to find out on its own.
236231

237-
5. Response codes
238-
-----------------
232+
Response codes
233+
--------------
239234

240235
The HTTP response code that the API gave is included in any return values.
241236
You can find it within the return object’s ```httpstatus``` property.
242237

243-
### 5.1 Dealing with rate-limits
238+
### Dealing with rate-limits
244239

245240
Basically, Codebird leaves it up to you to handle Twitter’s rate limit.
246241
The library returns the response HTTP status code, so you can detect rate limits.
@@ -252,10 +247,11 @@ See the [Rate Limiting FAQ](https://dev.twitter.com/docs/rate-limiting-faq)
252247
for more information.
253248

254249
Unless your return format is JOSN, you will receive rate-limiting details
255-
in the returned data’s ```$reply->rate``` property.
250+
in the returned data’s ```$reply->rate``` property,
251+
if the Twitter API responds with rate-limiting HTTP headers.
256252

257-
6. Return formats
258-
-----------------
253+
Return formats
254+
--------------
259255
The default return format for API calls is a PHP object.
260256
For API methods returning multiple data (like ```statuses/home_timeline```),
261257
you should cast the reply to array, like this:
@@ -278,10 +274,8 @@ To get a JSON string, set the corresponding return format:
278274
$cb->setReturnFormat(CODEBIRD_RETURNFORMAT_JSON);
279275
```
280276

281-
Support for getting a SimpleXML object is planned.
282-
283-
7. Using multiple Codebird instances
284-
------------------------------------
277+
Using multiple Codebird instances
278+
---------------------------------
285279

286280
By default, Codebird works with just one instance. This programming paradigma is
287281
called a *singleton*.
@@ -306,10 +300,9 @@ multiple Codebird instances, while the OAuth request and access tokens with thei
306300
secrets are *not* shared.
307301

308302
How Do I…?
309-
==========
303+
----------
310304

311-
…access a user’s profile image?
312-
-------------------------------
305+
### …access a user’s profile image?
313306

314307
First retrieve the user object using
315308

@@ -325,8 +318,7 @@ For example:
325318

326319
```$reply['profile_image_url']``` will then return the profile image url without https.
327320

328-
…get user ID, screen name and more details about the current user?
329-
------------------------------------------------------------------
321+
### …get user ID, screen name and more details about the current user?
330322

331323
When the user returns from the authentication screen, you need to trade
332324
the obtained request token for an access token, using the OAuth verifier.
@@ -362,8 +354,7 @@ print_r($reply);
362354
I suggest to cache the User Entity after obtaining it, as the
363355
```account/verify_credentials``` method is rate-limited by 15 calls per 15 minutes.
364356

365-
…walk through cursored results?
366-
-------------------------------
357+
### …walk through cursored results?
367358

368359
The Twitter REST API utilizes a technique called ‘cursoring’ to paginate
369360
large result sets. Cursoring separates results into pages of no more than
@@ -396,8 +387,7 @@ It might make sense to use the cursors in a loop. Watch out, though,
396387
not to send more than the allowed number of requests to ```followers/list```
397388
per rate-limit timeframe, or else you will hit your rate-limit.
398389

399-
…use xAuth with Codebird?
400-
-------------------------
390+
### …use xAuth with Codebird?
401391

402392
Codebird supports xAuth just like every other authentication used at Twitter.
403393
Remember that your application needs to be whitelisted to be able to use xAuth.
@@ -432,8 +422,7 @@ When this error occurs, advise the user to
432422
[generate a temporary password](https://twitter.com/settings/applications)
433423
on twitter.com and use that to complete signing in to the application.
434424

435-
…know what cacert.pem is for?
436-
-----------------------------
425+
### …know what cacert.pem is for?
437426

438427
Connections to the Twitter API are done over a secured SSL connection.
439428
Since 2.4.0, codebird-php checks if the Twitter API server has a valid
@@ -442,8 +431,7 @@ The cacert.pem file contains a list of all public certificates for root
442431
certificate authorities. You can find more information about this file
443432
at http://curl.haxx.se/docs/caextract.html.
444433

445-
…set the timeout for requests to the Twitter API?
446-
-------------------------------------------------
434+
### …set the timeout for requests to the Twitter API?
447435

448436
For connecting to Twitter, Codebird uses the cURL library.
449437
You can specify both the connection timeout and the request timeout,

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
22
"name": "jublonet/codebird-php",
33
"description" : "A Twitter library in PHP.",
4-
"version": "2.5.0-rc.1",
4+
"version": "2.5.0-rc.2",
55
"autoload": {
66
"classmap": ["src/"]
77
},
88
"license": "GPL-3.0",
99
"require": {
10+
"ext-curl": "*",
11+
"ext-hash": "*",
12+
"ext-json": "*",
1013
"lib-openssl": "*",
1114
"lib-curl": "*"
1215
}

0 commit comments

Comments
 (0)
0