aboutsummaryrefslogtreecommitdiffstats
path: root/include/api.php
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2011-11-08 00:18:37 -0800
committerfabrixxm <fabrix.xm@gmail.com>2011-11-08 00:18:37 -0800
commiteeec29c6be2429ea38ab258591200e0178886a25 (patch)
tree09f54a745f7ec828914e3ba7ee90492b0804ffef /include/api.php
parent9fabdbf2c974211c8fef18e48a956f8f38bd9e74 (diff)
parentc90e6c6e0782e3e8ac9cf1be3acbc13f5448148d (diff)
downloadvolse-hubzilla-eeec29c6be2429ea38ab258591200e0178886a25.tar.gz
volse-hubzilla-eeec29c6be2429ea38ab258591200e0178886a25.tar.bz2
volse-hubzilla-eeec29c6be2429ea38ab258591200e0178886a25.zip
Merge pull request #2 from fabrixxm/master
Oauth1 support in API
Diffstat (limited to 'include/api.php')
-rw-r--r--include/api.php47
1 files changed, 46 insertions, 1 deletions
diff --git a/include/api.php b/include/api.php
index d94cc2942..1196e0aac 100644
--- a/include/api.php
+++ b/include/api.php
@@ -2,7 +2,7 @@
require_once("bbcode.php");
require_once("datetime.php");
require_once("conversation.php");
-
+ require_once("oauth.php");
/*
* Twitter-Like API
*
@@ -27,6 +27,23 @@
* Simple HTTP Login
*/
function api_login(&$a){
+ // login with oauth
+ try{
+ $oauth = new FKOAuth1();
+ list($consumer,$token) = $oauth->verify_request(OAuthRequest::from_request());
+ if (!is_null($token)){
+ $oauth->loginUser($token->uid);
+ call_hooks('logged_in', $a->user);
+ return;
+ }
+ echo __file__.__line__.__function__."<pre>"; var_dump($consumer, $token); die();
+ }catch(Exception $e){
+ logger(__file__.__line__.__function__."\n".$e);
+ //die(__file__.__line__.__function__."<pre>".$e); die();
+ }
+
+
+
// workaround for HTTP-auth in CGI mode
if(x($_SERVER,'REDIRECT_REMOTE_USER')) {
$userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"],6)) ;
@@ -1127,3 +1144,31 @@
}
api_register_func('api/direct_messages/sent','api_direct_messages_sentbox',true);
api_register_func('api/direct_messages','api_direct_messages_inbox',true);
+
+
+
+ function api_oauth_request_token(&$a, $type){
+ try{
+ $oauth = new FKOAuth1();
+ $r = $oauth->fetch_request_token(OAuthRequest::from_request());
+ }catch(Exception $e){
+ echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme();
+ }
+ echo $r;
+ killme();
+ }
+ function api_oauth_access_token(&$a, $type){
+ try{
+ $oauth = new FKOAuth1();
+ $r = $oauth->fetch_access_token(OAuthRequest::from_request());
+ }catch(Exception $e){
+ echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme();
+ }
+ echo $r;
+ killme();
+ }
+
+ api_register_func('api/oauth/request_token', 'api_oauth_request_token', false);
+ api_register_func('api/oauth/access_token', 'api_oauth_access_token', false);
+
+