Commit: 2fd4e498ebd87087746e9756dbd1a437a74fee77
Author: gwoo | Date: 2010-03-13 10:23:32 -0800
diff --git a/config/routes.php b/config/routes.php
index d6b3c08..129d1e9 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -1,15 +1,15 @@
<?php
-use \lithium\http\Router;
+use \lithium\net\http\Router;
Router::connect('/oauth', array(
- 'plugin' => 'li3_oauth', 'controller' => 'server', 'action' => 'account'
+ 'library' => 'li3_oauth', 'controller' => 'li3_oauth.server', 'action' => 'account'
));
Router::connect('/oauth/client/{:action}/{:args}', array(
- 'plugin' => 'li3_oauth', 'controller' => 'client', 'action' => 'index'
+ 'library' => 'li3_oauth', 'controller' => 'li3_oauth.client', 'action' => 'index'
));
Router::connect('/oauth/{:action}/{:args}', array(
- 'plugin' => 'li3_oauth', 'controller' => 'server', 'action' => 'index'
+ 'library' => 'li3_oauth', 'controller' => 'li3_oauth.server', 'action' => 'index'
));
?>
\ No newline at end of file
diff --git a/controllers/ClientController.php b/controllers/ClientController.php
index 58ca96b..51dea7d 100644
--- a/controllers/ClientController.php
+++ b/controllers/ClientController.php
@@ -1,4 +1,10 @@
<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2009, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
namespace li3_oauth\controllers;
diff --git a/extensions/service/Oauth.php b/extensions/service/Oauth.php
index 85e250e..8cf41fe 100644
--- a/extensions/service/Oauth.php
+++ b/extensions/service/Oauth.php
@@ -23,7 +23,7 @@ class Oauth extends \lithium\core\Object {
* @var array
*/
protected $_classes = array(
- 'service' => '\lithium\http\Service',
+ 'service' => '\lithium\net\http\Service',
'storage' => '\li3_oauth\extensions\storage\File'
);
@@ -95,11 +95,24 @@ class Oauth extends \lithium\core\Object {
* @return void
*/
public function send($path = null, $data = null, $options = array()) {
+ $defaults = array('via' => 'header');
+ $options += $defaults;
$url = $this->config($path);
- $method = !empty($options['method']) ? $options['method'] : 'post';
+ $method = !empty($data['method']) ? $data['method'] : 'post';
$data = $this->sign($data + compact('url'));
+
+ if ($options['via'] == 'header') {
+ $auth = 'OAuth realm="",';
+ foreach ($data as $key => $val) {
+ $auth .= $key . '="'.rawurlencode($val).'",';
+ $auth .= "\n";
+ }
+ $options['headers'] = array('Authorization' => $auth);
+ $data = array();
+ }
$response = $this->service->send($method, $url, $data, $options);
- if (strpos($response, 'oauth_') === 0) {
+
+ if (strpos($response, 'oauth_token=') !== false) {
return $this->_decode($response);
}
return $response;
diff --git a/tests/mocks/extensions/service/MockService.php b/tests/mocks/extensions/service/MockService.php
index 4c14ac9..f909215 100644
--- a/tests/mocks/extensions/service/MockService.php
+++ b/tests/mocks/extensions/service/MockService.php
@@ -8,9 +8,9 @@
namespace li3_oauth\tests\mocks\extensions\service;
-class MockService extends \lithium\http\Service {
-
- public function send($method, $path = null, $data = null, $options = array()) {
+class MockService extends \lithium\net\http\Service {
+
+ public function send($method, $path = null, $data = null, array $options = array()) {
if (strpos($path, 'request_token') !== false) {
return 'oauth_token=requestkey&oauth_token_secret=requestsecret';
}
diff --git a/tests/mocks/extensions/service/MockStorage.php b/tests/mocks/extensions/service/MockStorage.php
index d95bdb2..6ee6583 100644
--- a/tests/mocks/extensions/service/MockStorage.php
+++ b/tests/mocks/extensions/service/MockStorage.php
@@ -8,7 +8,7 @@
namespace li3_oauth\tests\mocks\extensions\service;
-class MockStorage extends \lithium\http\Service {
+class MockStorage extends \lithium\net\http\Service {
protected $_data;