<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,12 +4,26 @@ error_reporting(E_ALL);
 require_once dirname(__FILE__).&quot;/../lib/fireeagle.php&quot;;
 
 function main() {
+    //To enable the new OAuth protocol, change the line at the end of this
+    //comment block. This tells FireEagle to use new OAuth protocol. Beware that
+    //this requires that you set the $fe_callback also. By default, the
+    //FireEagle class will behave as per the old OAUTH protocol. For details of
+    //the new OAuth, see the developer documentation at
+    //https://fireeagle.yahoo.net/developer/documentation/web_auth
+    FireEagle::$FE_OAUTH_VERSION = OAUTH_VERSION_10; //Use OAUTH_VERSION_10A for
+                                                     //new OAuth
 	
 	// hardcode your keys here
 	$fe_key = 'INSERT CONSUMER KEY HERE';
 	$fe_secret = 'INSERT CONSUMER SECRET HERE';
 
 	// or put them in walkthru_config.php, if you don't want to change this file
+
+    //For the new OAuth protocol, the URL registered at the Fire Eagle website
+    //for your web app will not work. Hardcode your application callback URL
+    //here. Don't forget to put '?f=callback'
+    $fe_callback = 'INSERT CALLBACK URL HERE'; //The string is ignored in old
+                                               //OAuth.
 	$cfn = dirname(__FILE__).&quot;/walkthru_config.php&quot;;
 	if (file_exists($cfn)) require_once($cfn);
 	
@@ -20,7 +34,7 @@ function main() {
 		// get a request token + secret from FE and redirect to the authorization page
 		// START step 1
 		$fe = new FireEagle($fe_key, $fe_secret);
-		$tok = $fe-&gt;getRequestToken();
+		$tok = $fe-&gt;getRequestToken($fe_callback);
 		if (!isset($tok['oauth_token'])
 		    || !is_string($tok['oauth_token'])
 		    || !isset($tok['oauth_token_secret'])
@@ -44,16 +58,21 @@ function main() {
 			echo &quot;Token mismatch.&quot;;
 			exit;
 		}
-		
+        if ((FireEagle::$FE_OAUTH_VERSION == OAUTH_VERSION_10A)
+            &amp;&amp; !isset($_GET['oauth_verifier'])) {
+            echo &quot;OAuth protocol error. No verifier in response.&quot;;
+            exit;
+        }
+
 		$fe = new FireEagle($fe_key, $fe_secret, $_SESSION['request_token'], $_SESSION['request_secret']);
-		$tok = $fe-&gt;getAccessToken();
+		$tok = $fe-&gt;getAccessToken($_GET['oauth_verifier']);
 		if (!isset($tok['oauth_token']) || !is_string($tok['oauth_token'])
 		    || !isset($tok['oauth_token_secret']) || !is_string($tok['oauth_token_secret'])) {
 			error_log(&quot;Bad token from FireEagle::getAccessToken(): &quot;.var_export($tok, TRUE));
 			echo &quot;ERROR! FireEagle::getAccessToken() returned an invalid response.  Giving up.&quot;;
 			exit;
 		}
-		
+
 		$_SESSION['access_token'] = $tok['oauth_token'];
 		$_SESSION['access_secret'] = $tok['oauth_token_secret'];
 		$_SESSION['auth_state'] = &quot;done&quot;;
@@ -136,4 +155,4 @@ function main() {
 
 main();
 
-?&gt;
\ No newline at end of file
+?&gt;</diff>
      <filename>example/walkthru.php</filename>
    </modified>
    <modified>
      <diff>@@ -100,10 +100,15 @@ class FireEagleException extends Exception {
   }
 }
 
+/* The OAuth version that governs the OAuth dance */
+define(&quot;OAUTH_VERSION_10&quot;, 1); //The old version.
+define(&quot;OAUTH_VERSION_10A&quot;, 2); //The new OAuth version 1.0 Rev A.
+
 /**
  * FireEagle API access helper class.
  */
 class FireEagle {
+  public static $FE_OAUTH_VERSION = OAUTH_VERSION_10; //Default to older version.
 
   public static $FE_ROOT = &quot;http://fireeagle.yahoo.net&quot;;
   public static $FE_API_ROOT = &quot;https://fireeagle.yahooapis.com&quot;;
@@ -176,14 +181,27 @@ class FireEagle {
    * @returns a key/value pair array containing: oauth_token and
    * oauth_token_secret.
    */
-  public function getRequestToken() {
-    $r = $this-&gt;oAuthRequest($this-&gt;requestTokenURL());
+  public function getRequestToken($callback=NULL) {
+    $params = array();
+    if (self::$FE_OAUTH_VERSION == OAUTH_VERSION_10A) {
+      if (empty($callback)) $callback = 'oob';
+      $params['oauth_callback'] = $callback;
+    }
+    $r = $this-&gt;oAuthRequest($this-&gt;requestTokenURL(), $params);
     $token = $this-&gt;oAuthParseResponse($r);
+    if (self::$FE_OAUTH_VERSION == OAUTH_VERSION_10A) {
+      if (empty($token['oauth_callback_confirmed'])
+          || (strcmp($token['oauth_callback_confirmed'], 'true') != 0))
+        throw new FireEagleException(&quot;Fire Eagle server is not talking the correct protocol&quot;, FireEagleException::REMOTE_ERROR);
+    }
     $this-&gt;token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']); // use this token from now on
     if (self::$FE_DUMP_REQUESTS) self::dump(&quot;Now the user is redirected to &quot;.$this-&gt;getAuthorizeURL($token['oauth_token']).&quot;\nOnce the user returns, via the callback URL for web authentication or manually for desktop authentication, we can get their access token and secret by calling /oauth/access_token.\n\n&quot;);
     return $token;
   }
-  public function request_token() { return $this-&gt;getRequestToken(); }
+
+  public function request_token($callback=NULL) {
+    return $this-&gt;getRequestToken($callback);
+  }
 
   /**
    * Get the URL to redirect to to authorize the user and validate a
@@ -206,14 +224,20 @@ class FireEagle {
    * @returns array(&quot;oauth_token&quot; =&gt; the access token,
    *                &quot;oauth_token_secret&quot; =&gt; the access secret)
    */
-  public function getAccessToken($token=NULL) {
+  public function getAccessToken($verifier=NULL) {
     $this-&gt;requireToken();
-    $r = $this-&gt;oAuthRequest($this-&gt;accessTokenURL());
+    $params = array();
+    if (self::$FE_OAUTH_VERSION == OAUTH_VERSION_10A) {
+      if (empty($verifier))
+        throw new FireEagleException(&quot;Access token verifier is empty&quot;, FireEagleException::REQUEST_FAILED);
+      $params['oauth_verifier'] = $verifier;
+    }
+    $r = $this-&gt;oAuthRequest($this-&gt;accessTokenURL(), $params);
     $token = $this-&gt;oAuthParseResponse($r);
     $this-&gt;token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']); // use this token from now on
     return $token;
   }
-  public function access_token() { return $this-&gt;getAccessToken(); }
+  public function access_token($verifier=NULL) { return $this-&gt;getAccessToken($verifier); }
 
   /**
    * Generic method call function.  You can use this to get the raw</diff>
      <filename>lib/fireeagle.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d31c0a591d2fca543d685aacf1cb32722009be25</id>
    </parent>
  </parents>
  <author>
    <name>Arnab Nandi</name>
    <email>arnob.nandi@gmail.com</email>
  </author>
  <url>http://github.com/myelin/fireeagle-php-lib/commit/1f2ea9d09e164ee58813be396d3cab66faf374ac</url>
  <id>1f2ea9d09e164ee58813be396d3cab66faf374ac</id>
  <committed-date>2009-05-31T09:50:29-07:00</committed-date>
  <authored-date>2009-05-31T09:50:29-07:00</authored-date>
  <message>Added capabilities for new OAuth dance. Default is still old one</message>
  <tree>38728e50f5767b3c0937f7b84aca08da712bd89f</tree>
  <committer>
    <name>Arnab Nandi</name>
    <email>arnob.nandi@gmail.com</email>
  </committer>
</commit>
