Skip to content

Commit

Permalink
Finish 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetx committed Jun 23, 2014
2 parents a3d23ca + 89acb6f commit b7adb5f
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_MESSAGE*
test*
*.jpg
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
codebird-js - changelog
=======================

2.5.0 (not yet released)
2.5.0 (2014-06-23)
+ #24 Add README section about xAuth
+ #46 Don't force to send base64 media uploads via proxy
+ #23 Support internal API methods
Expand All @@ -19,6 +19,7 @@ codebird-js - changelog
+ #60 Multiple media per tweet
+ #66 Support Titanium
- #71 Return rate-limiting info only if contained in response
- #72 Don't require consumer key if bearer token is already known

2.4.3 (2013-07-24)
- #31 HTTP error on multiple oauth_requestToken calls
Expand Down
52 changes: 45 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ If you already have your token, tell Codebird to use it:
```javascript
cb.setBearerToken("YOURBEARERTOKEN");
```

In this case, you don't need to set the consumer key and secret.
For sending an API request with app-only auth, see the ‘Usage examples’ section.

### Authenticating using a callback URL, without PIN
Expand Down Expand Up @@ -186,9 +186,7 @@ if (typeof parameters.oauth_verifier !== "undefined") {
Usage examples
--------------

### Heads up

*Because the Consumer Key and Token Secret are available in the code
:warning: *Because the Consumer Key and Token Secret are available in the code,
it is important that you configure your app as read-only at Twitter,
unless you are sure to know what you are doing.*

Expand Down Expand Up @@ -218,8 +216,35 @@ cb.__call(
);
```

For more complex parameters (see the [Twitter API documentation](https://dev.twitter.com/)),
giving all parameters in an array is supported, too:
:warning: *Make sure to urlencode any parameter values that contain
query-reserved characters, like tweeting the `&` sign:*

```javascript
var params = "status=" + encodeURIComponent("Fish & chips");
cb.__call(
"statuses_update",
params,
function (reply) {
// ...
}
);
```

In most cases, giving all parameters in an array is easier,
because no encoding is needed:

```javascript
var params = {
status: "Fish & chips"
};
cb.__call(
"statuses_update",
params,
function (reply) {
// ...
}
);
```

```javascript
var params = {
Expand All @@ -234,6 +259,19 @@ cb.__call(
);
```

```javascript
var params = {
q: "NYC"
};
cb.__call(
"search_tweets",
params,
function (reply) {
// ...
}
);
```

### Uploading files to Twitter

The array syntax is obligatory, and the media have to be base64-encoded:
Expand All @@ -256,7 +294,7 @@ cb.__call(
can be uploaded in a 2-step process. **First** you send each image to Twitter, like this:
```javascript
var params = {
"media_data": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB+0lEQVR42mP8//8/Ay0BEwONwagFoxZQDljI0PP8x7/Z93/e+PxXmpMpXp5dh4+ZgYHh0bd/clxYnMuINaMtfvRLgp3RVZwVU+rkuz+eRz+//wXVxcrEkKnEceXTX0dRlhoNTmKDaOvzXwHHv6x9+gtN/M9/hpjTX+GmMzAw/P7HMOnOj+ff//35x/Ds+z9iLfjPwPDt7//QE1/Sz319/RNh3PkPf+58+Yup/t7Xf9p8zFKcTMRa4CLGCrFm1v2fSjs+pJ/7uuvl7w+//yO7HRkUq3GEyrCREMk+kqy2IiyH3/xhYGD48uf/rPs/Z93/yczIwM3CiFU9Hw5xnD4ouvTt4Tf0AP37n+HTb+w+UOBmIs2CICm2R9/+EZlqGRkYzIVYSLMgRIYtUYGdSAsMBFgUuJhIy2iMDAwt2pysjAwLHv78RcgnOcrs5BQVHEyMG579Imi6Nh9zrBxZFgixMW624pXnwldYcTAzLjDhZmUit7AzE2K54c7fp8eF1QhWRobFptwmgiwkF3b//jMwMjJ8+P3/zPs/yx/9Wvr412+MgBJlZ1xsyuOOrbAibMHH3/87b32fce/nR2ypnpuFMVGevU6TQ5SdqKKeEVez5cuf/7te/j727s+9L/++/v3PzcyowM1kIcTiLs7Kz8pIfNnOONouGrVg1AIGAJ6gvN4J6V9GAAAAAElFTkSuQmCC"
"media": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB+0lEQVR42mP8//8/Ay0BEwONwagFoxZQDljI0PP8x7/Z93/e+PxXmpMpXp5dh4+ZgYHh0bd/clxYnMuINaMtfvRLgp3RVZwVU+rkuz+eRz+//wXVxcrEkKnEceXTX0dRlhoNTmKDaOvzXwHHv6x9+gtN/M9/hpjTX+GmMzAw/P7HMOnOj+ff//35x/Ds+z9iLfjPwPDt7//QE1/Sz319/RNh3PkPf+58+Yup/t7Xf9p8zFKcTMRa4CLGCrFm1v2fSjs+pJ/7uuvl7w+//yO7HRkUq3GEyrCREMk+kqy2IiyH3/xhYGD48uf/rPs/Z93/yczIwM3CiFU9Hw5xnD4ouvTt4Tf0AP37n+HTb+w+UOBmIs2CICm2R9/+EZlqGRkYzIVYSLMgRIYtUYGdSAsMBFgUuJhIy2iMDAwt2pysjAwLHv78RcgnOcrs5BQVHEyMG579Imi6Nh9zrBxZFgixMW624pXnwldYcTAzLjDhZmUit7AzE2K54c7fp8eF1QhWRobFptwmgiwkF3b//jMwMjJ8+P3/zPs/yx/9Wvr412+MgBJlZ1xsyuOOrbAibMHH3/87b32fce/nR2ypnpuFMVGevU6TQ5SdqKKeEVez5cuf/7te/j727s+9L/++/v3PzcyowM1kIcTiLs7Kz8pIfNnOONouGrVg1AIGAJ6gvN4J6V9GAAAAAElFTkSuQmCC"
);
cb.__call(
"media_upload",
Expand Down
31 changes: 31 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "codebird-js",
"version": "2.5.0",
"homepage": "http://www.jublo.net/projects/codebird/js",
"authors": [
"Joshua Atkins <joshua.atkins@jublo.net>",
"J.M. <jm@jublo.net>"
],
"description": "A Twitter library in JavaScript.",
"main": "codebird.js",
"moduleType": [
"amd",
"globals",
"node"
],
"keywords": [
"Twitter",
"API",
"networking",
"CORS"
],
"license": "GPL-3.0+",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"RELEASE_MESSAGE*",
"test",
"tests"
]
}
47 changes: 22 additions & 25 deletions codebird.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
/**
* A Twitter library in JavaScript
*
* @package codebird
* @version 2.5.0-rc.2
* @author Jublo Solutions <support@jublo.net>
* @package codebird
* @version 2.5.0
* @author Jublo Solutions <support@jublo.net>
* @copyright 2010-2014 Jublo Solutions <support@jublo.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* @license http://opensource.org/licenses/GPL-3.0 GNU Public License 3.0
* @link https://github.com/jublonet/codebird-php
*/

/* jshint curly: true,
Expand Down Expand Up @@ -146,7 +135,7 @@ var Codebird = function () {
/**
* The current Codebird version
*/
var _version = "2.5.0-rc.2";
var _version = "2.5.0";

/**
* Sets the OAuth consumer key and secret (App key)
Expand Down Expand Up @@ -1331,7 +1320,7 @@ var Codebird = function () {
params.application_id = 333903271;
}

var url = _getEndpoint(method);
var url = _getEndpoint(method);
var authorization = null;

var xml = _getXmlRequestObject();
Expand All @@ -1345,7 +1334,9 @@ var Codebird = function () {
if (JSON.stringify(params) !== "{}") {
url_with_params += "?" + _http_build_query(params);
}
authorization = _sign(httpmethod, url, params);
if (! app_only_auth) {
authorization = _sign(httpmethod, url, params);
}

// append auth params to GET url for IE7-9, to send via JSONP
if (_use_jsonp) {
Expand Down Expand Up @@ -1395,11 +1386,15 @@ var Codebird = function () {
return;
}
if (multipart) {
authorization = _sign(httpmethod, url, {});
params = _buildMultipart(method, params);
if (! app_only_auth) {
authorization = _sign(httpmethod, url, {});
}
params = _buildMultipart(method, params);
} else {
authorization = _sign(httpmethod, url, params);
params = _http_build_query(params);
if (! app_only_auth) {
authorization = _sign(httpmethod, url, params);
}
params = _http_build_query(params);
}
post_fields = params;
if (_use_proxy || multipart) { // force proxy for multipart base64
Expand All @@ -1420,8 +1415,10 @@ var Codebird = function () {
}
}
if (app_only_auth) {
if (_oauth_consumer_key === null) {
console.warn("To make an app-only auth API request, the consumer key must be set.");
if (_oauth_consumer_key === null
&& _oauth_bearer_token === null
) {
console.warn("To make an app-only auth API request, consumer key or bearer token must be set.");
}
// automatically fetch bearer token, if necessary
if (_oauth_bearer_token === null) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codebird",
"version": "2.5.0-rc.2",
"version": "2.5.0",
"description": "A Twitter library in JavaScript.",
"keywords": [
"Twitter",
Expand Down

0 comments on commit b7adb5f

Please sign in to comment.