Permalink
Browse files

Version 0.7.0

- changed version numbers to x.y.z format
- stronger method scoping (public and private)
- Typo fix in depenencies. (Issue #42) Props: tantek
- Only lowercase the host and scheme, and not path, in prepare_url. (Issue #56) Props: uzyn
- Fixed a number of PHP warnings by changing some tmhUtilty methods to static. (Issue #52) Props: DrayChou
- Raw headers and response body are now available as `$tmhOAuth->response['raw']`
- Moved the examples to their own repository <https://github.com/themattharris/tmhOAuth-examples>
- Removed the `noexamples` branch as master does not contain examples anymore
- Introduced `$tmhOAuth->config['timezone']` and set `date_default_timezone_set`. (Issue #70) Props: iamctodd
  • Loading branch information...
1 parent d0b0bc6 commit d3034a18dc28170957be50a4151de3f0a3f4eea7 @themattharris committed with themattharris Sep 4, 2012
View
@@ -23,7 +23,7 @@ of PHP is lower than this you should ask your hosting provider for an update.
## A note about security and SSL
-Version 0.60 hardens the security of the library and defaults `curl_ssl_verifypeer` to `true`.
+Version 0.60 hardened the security of the library and defaulted `curl_ssl_verifypeer` to `true`.
As some hosting providers do not provide the most current certificate root file
it is now included in this repository. If the version is out of date OR you prefer
to download the certificate roots yourself, you can get them
@@ -34,8 +34,9 @@ handling works on your server by running the `examples/verify_ssl.php` script.
## Usage
-This will be built out later but for the moment review the examples for ways
-the library can be used. Each example contains instructions on how to use it
+This will be built out later but for the moment review the examples repository
+<https://github.com/themattharris/tmhOAuth-examples> for ways the library can be
+used. Each example contains instructions on how to use it.
## Notes for users of previous versions
@@ -46,10 +47,20 @@ test locally to ensure your code doesn't need tmhUtilities included.
If you used custom HTTP request headers when they were defined as `'key: value'` strings
you should now define them as `'key' => 'value'` pairs.
-## Change History ##
+## Change History
+### 0.7.0 - 04 September 2012
+- changed version numbers to x.y.z format
+- stronger method scoping (public and private)
+- Typo fix in depenencies. (Issue #42) Props: tantek
+- Only lowercase the host and scheme, and not path, in prepare_url. (Issue #56) Props: uzyn
+- Fixed a number of PHP warnings by changing some tmhUtilty methods to static. (Issue #52) Props: DrayChou
+- Raw headers and response body are now available as `$tmhOAuth->response['raw']`
+- Moved the examples to their own repository <https://github.com/themattharris/tmhOAuth-examples>
+- Removed the `noexamples` branch as master does not contain examples anymore
+- Introduced `$tmhOAuth->config['timezone']` and set `date_default_timezone_set`. (Issue #70) Props: iamctodd
### 0.621 - 12 March 2012
-- Ensure $_SERVER['HTTPS'] isset before checking it's value. Props: kud
+- Ensure `$_SERVER['HTTPS']` isset before checking it's value. Props: kud
### 0.62 - 01 March 2012
- Fix array merging bug. Props: julien-c
@@ -159,7 +170,7 @@ you should now define them as `'key' => 'value'` pairs.
License: Apache 2 (see included LICENSE file)
Follow me on Twitter: <https://twitter.com/intent/follow?screen_name=themattharris>
-Check out the Twitter Developer Resources: <http://dev.twitter.com>
+Check out the Twitter Developer Resources: <https://dev.twitter.com>
## To Do
View
@@ -1,112 +0,0 @@
-<?php
-
-/**
- * Demonstration of the various OAuth flows. You would typically do this
- * when an unknown user is first using your application. Instead of storing
- * the token and secret in the session you would probably store them in a
- * secure database with their logon details for your website.
- *
- * When the user next visits the site, or you wish to act on their behalf,
- * you would use those tokens and skip this entire process.
- *
- * The Sign in with Twitter flow directs users to the oauth/authenticate
- * endpoint which does not support the direct message permission. To obtain
- * direct message permissions you must use the "Authorize Application" flows.
- *
- * 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) Visit this page using your web browser.
- *
- * @author themattharris
- */
-
-require '../tmhOAuth.php';
-require '../tmhUtilities.php';
-$tmhOAuth = new tmhOAuth(array(
- 'consumer_key' => 'YOUR_CONSUMER_KEY',
- 'consumer_secret' => 'YOUR_CONSUMER_SECRET',
-));
-
-$here = tmhUtilities::php_self();
-session_start();
-
-function outputError($tmhOAuth) {
- echo 'Error: ' . $tmhOAuth->response['response'] . PHP_EOL;
- tmhUtilities::pr($tmhOAuth);
-}
-
-// reset request?
-if ( isset($_REQUEST['wipe'])) {
- session_destroy();
- header("Location: {$here}");
-
-// already got some credentials stored?
-} elseif ( isset($_SESSION['access_token']) ) {
- $tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token'];
- $tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret'];
-
- $code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials'));
- if ($code == 200) {
- $resp = json_decode($tmhOAuth->response['response']);
- echo $resp->screen_name;
- } else {
- outputError($tmhOAuth);
- }
-// we're being called back by Twitter
-} elseif (isset($_REQUEST['oauth_verifier'])) {
- $tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token'];
- $tmhOAuth->config['user_secret'] = $_SESSION['oauth']['oauth_token_secret'];
-
- $code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/access_token', ''), array(
- 'oauth_verifier' => $_REQUEST['oauth_verifier']
- ));
-
- if ($code == 200) {
- $_SESSION['access_token'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
- unset($_SESSION['oauth']);
- header("Location: {$here}");
- } else {
- outputError($tmhOAuth);
- }
-// start the OAuth dance
-} elseif ( isset($_REQUEST['authenticate']) || isset($_REQUEST['authorize']) ) {
- $callback = isset($_REQUEST['oob']) ? 'oob' : $here;
-
- $params = array(
- 'oauth_callback' => $callback
- );
-
- if (isset($_REQUEST['force_write'])) :
- $params['x_auth_access_type'] = 'write';
- elseif (isset($_REQUEST['force_read'])) :
- $params['x_auth_access_type'] = 'read';
- endif;
-
- $code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/request_token', ''), $params);
-
- if ($code == 200) {
- $_SESSION['oauth'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
- $method = isset($_REQUEST['authenticate']) ? 'authenticate' : 'authorize';
- $force = isset($_REQUEST['force']) ? '&force_login=1' : '';
- $authurl = $tmhOAuth->url("oauth/{$method}", '') . "?oauth_token={$_SESSION['oauth']['oauth_token']}{$force}";
- echo '<p>To complete the OAuth flow follow this URL: <a href="'. $authurl . '">' . $authurl . '</a></p>';
- } else {
- outputError($tmhOAuth);
- }
-}
-
-?>
-<ul>
- <li><a href="?authenticate=1">Sign in with Twitter</a></li>
- <li><a href="?authenticate=1&amp;force=1">Sign in with Twitter (force login)</a></li>
- <li><a href="?authorize=1">Authorize Application (with callback)</a></li>
- <li><a href="?authorize=1&amp;oob=1">Authorize Application (oob - pincode flow)</a></li>
- <li><a href="?authorize=1&amp;force_read=1">Authorize Application (with callback) (force read-only permissions)</a></li>
- <li><a href="?authorize=1&amp;force_write=1">Authorize Application (with callback) (force read-write permissions)</a></li>
- <li><a href="?authorize=1&amp;force=1">Authorize Application (with callback) (force login)</a></li>
- <li><a href="?wipe=1">Start Over and delete stored tokens</a></li>
-</ul>
View
@@ -1,51 +0,0 @@
-<?php
-
-/**
- * Verify the user token and secret works. If successful we will be given the
- * details of the user. If not an error explaining why will be returned.
- *
- * Although this example uses your user token/secret, you can use
- * the user token/secret of any user who has authorised your application.
- *
- * This example differs from others in that it will reattempt a request if
- * the timestamp is detected to be off from the Twitter servers.
- *
- * 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)
- * 4) Visit this page using your web browser.
- *
- * @author themattharris
- */
-
-require '../tmhOAuth.php';
-require '../tmhUtilities.php';
-$tmhOAuth = new tmhOAuth(array(
- 'consumer_key' => 'YOUR_CONSUMER_KEY',
- 'consumer_secret' => 'YOUR_CONSUMER_SECRET',
- 'user_token' => 'A_USER_TOKEN',
- 'user_secret' => 'A_USER_SECRET',
-));
-
-// for the demo set the timestamp to yesterday
-$tmhOAuth->config['force_timestamp'] = true;
-$tmhOAuth->config['timestamp'] = strtotime('yesterday');
-
-$code = tmhUtilities::auto_fix_time_request($tmhOAuth, 'GET', $tmhOAuth->url('1/account/verify_credentials'));
-
-if ($code == 200) {
- if ($tmhOAuth->auto_fixed_time)
- echo 'Had to auto adjust the time. Please check the date and time is correct on your device/server';
-
- tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
-} else {
- tmhUtilities::pr(htmlentities($tmhOAuth->response['response']));
-}
-
-?>
View
@@ -1,89 +0,0 @@
-<!DOCTYPE html>
-<head>
- <meta charset="UTF-8" />
-</head>
-<body>
-<?php
-
-/**
- * Render a very rough timeline with entities included.
- *
- * Although this example uses your user token/secret, you can use
- * the user token/secret of any user who has authorised your application.
- *
- * 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)
- * 4) Visit this page using your web browser.
- *
- * @author themattharris
- */
-
-date_default_timezone_set('UTC');
-
-require '../tmhOAuth.php';
-require '../tmhUtilities.php';
-$tmhOAuth = new tmhOAuth(array(
- 'consumer_key' => 'YOUR_CONSUMER_KEY',
- 'consumer_secret' => 'YOUR_CONSUMER_SECRET',
- 'user_token' => 'A_USER_TOKEN',
- 'user_secret' => 'A_USER_SECRET',
-));
-
-$code = $tmhOAuth->request('GET', $tmhOAuth->url('1/statuses/user_timeline'), array(
- 'include_entities' => '1',
- 'include_rts' => '1',
- 'screen_name' => 'themattharris',
- 'count' => 100,
-));
-
-if ($code == 200) {
- $timeline = json_decode($tmhOAuth->response['response'], true);
- foreach ($timeline as $tweet) :
- $entified_tweet = tmhUtilities::entify_with_options($tweet);
- $is_retweet = isset($tweet['retweeted_status']);
-
- $diff = time() - strtotime($tweet['created_at']);
- if ($diff < 60*60)
- $created_at = floor($diff/60) . ' minutes ago';
- elseif ($diff < 60*60*24)
- $created_at = floor($diff/(60*60)) . ' hours ago';
- else
- $created_at = date('d M', strtotime($tweet['created_at']));
-
- $permalink = str_replace(
- array(
- '%screen_name%',
- '%id%',
- '%created_at%'
- ),
- array(
- $tweet['user']['screen_name'],
- $tweet['id_str'],
- $created_at,
- ),
- '<a href="https://twitter.com/%screen_name%/%id%">%created_at%</a>'
- );
-
- ?>
- <div id="<?php echo $tweet['id_str']; ?>" style="margin-bottom: 1em">
- <span>ID: <?php echo $tweet['id_str']; ?></span><br>
- <span>Orig: <?php echo $tweet['text']; ?></span><br>
- <span>Entitied: <?php echo $entified_tweet ?></span><br>
- <small><?php echo $permalink ?><?php if ($is_retweet) : ?>is retweet<?php endif; ?>
- <span>via <?php echo $tweet['source']?></span></small>
- </div>
-<?php
- endforeach;
-} else {
- tmhUtilities::pr($tmhOAuth->response);
-}
-?>
-</body>
-</html>
Oops, something went wrong.

0 comments on commit d3034a1

Please sign in to comment.