Permalink
Browse files

- Fixed issue where headers were being duplicated if the library was …

…called more than once.

- Updated examples to fit the new location of access tokens and secrets on dev.twitter.com
- Added Photo Tweet example
  • Loading branch information...
1 parent f901f04 commit 123db458967a219c2301807f8c9682e4edffe26d @themattharris committed Aug 15, 2011
View
@@ -3,7 +3,10 @@
An OAuth 1.0A library written in PHP by @themattharris, specifically for use
with the Twitter API.
-**Important**: If you previously used version 0.4 be aware the utility functions
+**Important**: If you used custom HTTP request headers they should now be defined
+as `'key' => 'value'` pairs instead of complete `'key: value'` strings.
+
+If you previously used version 0.4 be aware the utility functions
have now been broken into their own file. Before you use version 0.5+ in your app
test locally to ensure your code doesn't need tmhUtilities included.
@@ -32,6 +35,11 @@ the library can be used. Each example contains instructions on how to use it
## Change History
+### 0.53 - 15 July 2011
+- Fixed issue where headers were being duplicated if the library was called more than once.
+- Updated examples to fit the new location of access tokens and secrets on dev.twitter.com
+- Added Photo Tweet example
+
### 0.52 - 06 July 2011
- Fixed issue where the preference for include_time in create_nonce was being ignored
View
@@ -15,7 +15,7 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
View
@@ -12,15 +12,14 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) Visit this page using your web browser.
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) Visit this page using your web browser.
*
* @author themattharris
*/
View
@@ -13,15 +13,14 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) Visit this page using your web browser.
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) Visit this page using your web browser.
*
* @author themattharris
*/
View
@@ -9,15 +9,14 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) Visit this page using your web browser.
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) Visit this page using your web browser.
*
* @author themattharris
*/
View
@@ -12,16 +12,16 @@
* the user token/secret of any user who has authorised your application.
*
* Instructions:
+ * Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) Visit this page using your web browser.
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) Visit this page using your web browser.
*
* @author themattharris
*/
View
@@ -8,15 +8,14 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) Visit this page using your web browser.
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) Visit this page using your web browser.
*
* @author themattharris
*/
@@ -42,16 +41,15 @@ function generate_verify_header($tmhOAuth) {
function prepare_request($tmhOAuth) {
// create the headers for the echo
$headers = array(
- 'X-Auth-Service-Provider: ' . $tmhOAuth->url('1/account/verify_credentials'),
- 'X-Verify-Credentials-Authorization: ' . $tmhOAuth->auth_header,
+ 'X-Auth-Service-Provider' => $tmhOAuth->url('1/account/verify_credentials'),
+ 'X-Verify-Credentials-Authorization' => $tmhOAuth->auth_header,
);
// load the headers for the request
$tmhOAuth->headers = $headers;
-
// prepare the request to posterous
$params = array(
- 'media' => "@{$_FILES['file']['tmp_name']};type={$_FILES['file']['type']};filename={$_FILES['file']['name']}",
+ 'media' => "@{$_FILES['file']['tmp_name']};type={$_FILES['file']['type']};filename={$_FILES['file']['name']}",
'message' => 'trying something out'
);
@@ -69,7 +67,7 @@ function make_request($tmhOAuth, $url, $params, $auth, $multipart) {
return false;
}
-if ( ! empty($_FILES)) {
+if (TRUE || ! empty($_FILES)) {
// IMPORTANT: Posterous requires the host be https://api.twitter.com
// versions 0.11+ of tmhOAuth default to SSL so do not need changing
View
@@ -13,7 +13,7 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
@@ -37,7 +37,7 @@ function outputError($tmhOAuth) {
function wipe() {
session_destroy();
- header("Location: {$here}");
+ header('Location: ' . tmhUtilities::php_self());
}
@@ -86,7 +86,7 @@ function access_token($tmhOAuth) {
if ($code == 200) {
$_SESSION['access_token'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
unset($_SESSION['oauth']);
- header("Location: {$here}");
+ header('Location: ' . tmhUtilities::php_self());
} else {
outputError($tmhOAuth);
}
View
@@ -4,8 +4,9 @@
* Obtain a users token and secret using xAuth.
* This example is intended to be run from the command line. To use it:
*
+ * Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
View
@@ -7,18 +7,20 @@
* Although this example uses your user token/secret, you can use
* the oauth_token/secret of any user who has authorised your application.
*
+ * This example is intended to be run from the command line.
+ *
* Instructions:
* 1) If you don't have one already, create a Twitter application on
* https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
* 3) From the application details page copy the access token and access token
- * secret into the place in this code marked with (A_USER_TOKEN
- * and A_USER_SECRET)
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
* 4) Update $image to point to a real image file on your computer.
* 5) In a terminal or server type:
- * php /path/to/here/photo_tweet.php
+ * php /path/to/here/photo_tweet.php
*
* @author themattharris
*/
@@ -36,15 +38,14 @@
// an uploaded image - see images.php in the examples folder for how to do this
// 'image = "@{$_FILES['image']['tmp_name']};type={$_FILES['image']['type']};filename={$_FILES['image']['name']}",
-// for better support you should set image to something like:
-// $image = "{$image};type={MIMETYPE};filename={FILENAME}"
-$image = 'guitar.jpg';
+// this is the jpeg file to upload. It should be in the same directory as this file.
+$image = 'image.jpg';
$code = $tmhOAuth->request(
'POST',
'https://upload.twitter.com/1/statuses/update_with_media.json',
array(
- 'media[]' => "@{$image}",
+ 'media[]' => "@{$image};type=image/jpeg;filename={$image}",
'status' => 'Picture time',
),
true, // use auth
View
@@ -8,15 +8,14 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) Visit this page using your web browser.
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) Visit this page using your web browser.
*
* @author themattharris
*/
View
@@ -6,6 +6,7 @@
*
* This example is intended to be run from the command line. To use it:
*
+ * Instructions:
* 1) If you don't have one already, create a Twitter application on
* http://dev.twitter.com/apps
* 2) Note your the consumer key and consumer secret for the application
View
@@ -9,19 +9,19 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) In a terminal or server type:
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) In a terminal or server type:
* php /path/to/here/sitestream.php
- * 7) To stop the Streaming API either press CTRL-C or, in the folder the
+ * 5) To stop the Streaming API either press CTRL-C or, in the folder the
* script is running from type:
* touch STOP
+ *
* @author themattharris
*/
View
@@ -6,19 +6,19 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) In a terminal or server type:
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) In a terminal or server type:
* php /path/to/here/streaming.php
- * 7) To stop the Streaming API either press CTRL-C or, in the folder the
+ * 5) To stop the Streaming API either press CTRL-C or, in the folder the
* script is running from type:
* touch STOP
+ *
* @author themattharris
*/
@@ -9,19 +9,19 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) In a terminal or server type:
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) In a terminal or server type:
* php /path/to/here/streaming.php
- * 7) To stop the Streaming API either press CTRL-C or, in the folder the
+ * 5) To stop the Streaming API either press CTRL-C or, in the folder the
* script is running from type:
* touch STOP
+ *
* @author themattharris
*/
View
@@ -8,15 +8,14 @@
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
- * http://dev.twitter.com/apps
+ * https://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
- * 4) Visit the 'My Access Token' screen linked to from your application
- * details page
- * 5) Copy the user token and user secret into the place in this code marked
- * with (A_USER_TOKEN and A_USER_SECRET)
- * 6) Visit this page using your web browser.
+ * 3) From the application details page copy the access token and access token
+ * secret into the place in this code marked with (A_USER_TOKEN
+ * and A_USER_SECRET)
+ * 4) Visit this page using your web browser.
*
* @author themattharris
*/
Oops, something went wrong.

0 comments on commit 123db45

Please sign in to comment.