8000 Finish 2.5.0 · redaxeprogrammers/codebird-php@17a1eb1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 17a1eb1

Browse files
committed
Finish 2.5.0
2 parents deb2a83 + 38b88fe commit 17a1eb1

File tree

7 files changed

+97
-17
lines changed

7 files changed

+97
-17
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RELEASE_MESSAGE*
2+
test*
3+
*.jpg

CHANGELOG

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
codebird-php - changelog
22
========================
33

4-
2.5.0 (not yet released)
4+
2.5.0 (2014-06-20)
55
+ Add section about cacert.pem to README
66
+ Option to set cURL timeout
77
+ #42 Allow to get the supported API methods as array
@@ -16,6 +16,7 @@ codebird-php - changelog
1616
+ #61 Return rate limit details with each API call
1717
+ #60 Support uploading multiple media
1818
- #63 Return rate-limiting info only if contained in response
19+
- #57 Don't require consumer key if bearer token is already known
1920

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

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ If you already have your token, tell Codebird to use it:
108108
```php
109109
\Codebird\Codebird::setBearerToken('YOURBEARERTOKEN');
110110
```
111-
111+
In this case, you don't need to set the consumer key and secret.
112112
For sending an API request with app-only auth, see the ‘Usage examples’ section.
113113

114114

@@ -130,8 +130,24 @@ Tweeting is as easy as this:
130130
$reply = $cb->statuses_update('status=Whohoo, I just tweeted!');
131131
```
132132

133-
For more complex parameters (see the [Twitter API documentation](https://dev.twitter.com/)),
134-
giving all parameters in an array is supported, too:
133+
:warning: *Make sure to urlencode any parameter values that contain
134+
query-reserved characters, like tweeting the `&` sign:*
135+
136+
```php
137+
$reply = $cb->statuses_update('status=' . urlencode('Fish & chips'));
138+
// will result in this:
139+
$reply = $cb->statuses_update('status=Fish+%26+chips');
140+
```
141+
142+
In most cases, giving all parameters in an array is easier,
143+
because no encoding is needed:
144+
145+
```php
146+
$params = array(
147+
'status' => 'Fish & chips'
148+
);
149+
$reply = $cb->statuses_update($params);
150+
```
135151

136152
```php
137153
$params = array(

bower.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "codebird-php",
3+
"version": "2.5.0",
4+
"homepage": "http://www.jublo.net/projects/codebird/php",
5+
"authors": [
6+
"Joshua Atkins <joshua.atkins@jublo.net>",
7+
"J.M. <jm@jublo.net>"
8+
],
9+
"description": "A Twitter library in PHP.",
10+
"main": "src/codebird.php",
11+
"moduleType": [],
12+
"keywords": [
13+
"Twitter",
14+
"API",
15+
"networking"
16+
],
17+
"license": "GPL-3.0+",
18+
"ignore": [
19+
"**/.*",
20+
"node_modules",
21+
"bower_components",
22+
"test",
23+
"tests"
24+
]
25+
}

composer.json

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
11
{
22
"name": "jublonet/codebird-php",
33
"description" : "A Twitter library in PHP.",
4-
"version": "2.5.0-rc.2",
5-
"autoload": {
6-
"classmap": ["src/"]
7-
},
4+
"keywords": [
5+
"Twitter",
6+
"API",
7+
"networking"
8+
],
9+
"homepage": "http://www.jublo.net/projects/codebird/php",
810
"license": "GPL-3.0",
11+
"authors": [
12+
{
13+
"name": "Joshua Atkins",
14+
"email": "joshua.atkins@jublo.net",
15+
"homepage": "http://atkins.im/",
16+
"role": "Developer"
17+
},
18+
{
19+
"name": "J.M.",
20+
"email": "jm@jublo.net",
21+
"homepage": "http://mynetx.net/",
22+
"role": "Developer"
23+
}
24+
],
25+
"support": {
26+
"email": "support@jublo.net",
27+
"issues": "https://github.com/jublonet/codebird-php/issues",
28+
"source": "https://github.com/jublonet/codebird-php/releases"
29+
},
930
"require": {
1031
"ext-curl": "*",
1132
"ext-hash": "*",
1233
"ext-json": "*",
1334
"lib-openssl": "*",
1435
"lib-curl": "*"
36+
},
37+
"autoload": {
38+
"classmap": ["src/"]
1539
}
1640
}

src/codebird.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* A Twitter library in PHP.
77
*
88
* @package codebird
9-
* @version 2.5.0-rc.2
9+
* @version 2.5.0
1010
* @author Jublo Solutions <support@jublo.net>
1111
* @copyright 2010-2014 Jublo Solutions <support@jublo.net>
1212
*
@@ -117,7 +117,7 @@ class Codebird
117117
/**
118118
* The current Codebird version
119119
*/
120-
protected $_version = '2.5.0-rc.2';
120+
protected $_version = '2.5.0';
121121

122122
/**
123123
* Request timeout
@@ -1051,21 +1051,28 @@ protected function _callApi($httpmethod, $method, $params = array(), $multipart
10511051
$params['application_id'] = 333903271;
10521052
}
10531053

1054-
$url = $this->_getEndpoint($method);
1054+
$authorization = null;
1055+
$url = $this->_getEndpoint($method);
10551056
$request_headers = array();
10561057
if ($httpmethod === 'GET') {
10571058
$url_with_params = $url;
10581059
if (json_encode($params) !== '{}') {
10591060
$url_with_params .= '?' . http_build_query($params);
10601061
}
1061-
$authorization = $this->_sign($httpmethod, $url, $params);
1062+
if (! $app_only_auth) {
1063+
$authorization = $this->_sign($httpmethod, $url, $params);
1064+
}
10621065
$ch = curl_init($url_with_params);
10631066
} else {
10641067
if ($multipart) {
1065-
$authorization = $this->_sign($httpmethod, $url, array());
1066-
$params = $this->_buildMultipart($method, $params);
1068+
if (! $app_only_auth) {
1069+
$authorization = $this->_sign($httpmethod, $url, array());
1070+
}
1071+
$params = $this->_buildMultipart($method, $params);
10671072
} else {
1068-
$authorization = $this->_sign($httpmethod, $url, $params);
1073+
if (! $app_only_auth) {
1074+
$authorization = $this->_sign($httpmethod, $url, $params);
1075+
}
10691076
$params = http_build_query($params);
10701077
}
10711078
$ch = curl_init($url);
@@ -1079,8 +1086,10 @@ protected function _callApi($httpmethod, $method, $params = array(), $multipart
10791086
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
10801087
}
10811088
if ($app_only_auth) {
1082-
if (self::$_oauth_consumer_key === null) {
1083-
throw new \Exception('To make an app-only auth API request, the consumer key must be set.');
1089+
if (self::$_oauth_consumer_key === null
1090+
&& self::$_oauth_bearer_token === null
1091+
) {
1092+
throw new \Exception('To make an app-only auth API request, consumer key or bearer token must be set.');
10841093
}
10851094
// automatically fetch bearer token, if necessary
10861095
if (self::$_oauth_bearer_token === null) {

0 commit comments

Comments
 (0)
0