Skip to content

Commit

Permalink
quite a few changes to move to 2.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridauth committed Nov 23, 2011
1 parent b52838a commit a9d4f53
Show file tree
Hide file tree
Showing 54 changed files with 2,909 additions and 3,741 deletions.
7 changes: 0 additions & 7 deletions README.md
Expand Up @@ -52,10 +52,3 @@ at [http://hybridauth.sourceforge.net/userguide.html](http://hybridauth.sourcefo

**To get help and support**, join us and participate in the hybriauth discussion group
at [http://hybridauth.sourceforge.net/support.html](http://hybridauth.sourceforge.net/support.html)

## Quick Start

- CHMOD 777 config.php
- Run install.php.
- Once configured, delete install.php.
That's it!
125 changes: 23 additions & 102 deletions additional-providers/hybridauth-Identica/Providers/Identica.php
@@ -1,119 +1,40 @@
<?php
/**
/*!
* HybridAuth
*
* A Social-Sign-On PHP Library for authentication through identity providers like Facebook,
* Twitter, Google, Yahoo, LinkedIn, MySpace, Windows Live, Tumblr, Friendster, OpenID, PayPal,
* Vimeo, Foursquare, AOL, Gowalla, and others.
*
* Copyright (c) 2009-2011 (http://hybridauth.sourceforge.net)
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
*/

/**
* Hybrid_Providers_Identica class
* Hybrid_Providers_Identica
*/
class Hybrid_Providers_Identica extends Hybrid_Provider_Model
class Hybrid_Providers_Identica extends Hybrid_Provider_Model_OAuth1
{
/**
/**
* IDp wrappers initializer
*/
function initialize()
{
if ( ! $this->config["keys"]["key"] || ! $this->config["keys"]["secret"] )
{
throw new Exception( "Your application key and secret are required in order to connect to {$this->providerId}.", 4 );
}

require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth.php";
require_once Hybrid_Auth::$config["path_libraries"] . "TwitterCompatible/TwitterCompatibleClient.php";
require_once Hybrid_Auth::$config["path_libraries"] . "TwitterCompatible/Identica.php";

if( $this->token( "access_token" ) && $this->token( "access_token_secret" ) )
{
$this->api = new Identica_Client
(
$this->config["keys"]["key"], $this->config["keys"]["secret"],
$this->token( "access_token" ), $this->token( "access_token_secret" )
);
}
}

/**
* begin login step
*/
function loginBegin()
{
$this->api = new Identica_Client( $this->config["keys"]["key"], $this->config["keys"]["secret"] );

$tokz = $this->api->getRequestToken( $this->endpoint );

// check the last HTTP status code returned
if ( $this->api->http_code != 200 )
{
throw new Exception( "Authentification failed! {$this->providerId} returned an error: " . $this->api->lastErrorMessageFromStatus(), 5 );
}

if ( ! isset( $tokz["oauth_token"] ) )
{
throw new Exception( "Authentification failed! {$this->providerId} returned an invalid oauth token.", 5 );
}

$this->token( "request_token" , $tokz["oauth_token"] );
$this->token( "request_token_secret", $tokz["oauth_token_secret"] );

# redirect user to twitter
Hybrid_Auth::redirect( $this->api->getAuthorizeURL( $tokz ) );
}

/**
* finish login step
*/
function loginFinish()
{
$oauth_token = @ $_REQUEST['oauth_token'];
$oauth_verifier = @ $_REQUEST['oauth_verifier'];

if ( ! $oauth_token || ! $oauth_verifier )
{
throw new Exception( "Authentification failed! {$this->providerId} returned an invalid oauth verifier.", 5 );
}

$this->api = new Identica_Client(
$this->config["keys"]["key"], $this->config["keys"]["secret"],
$this->token( "request_token" ), $this->token( "request_token_secret" )
);

$tokz = $this->api->getAccessToken( $oauth_verifier );

// check the last HTTP status code returned
if ( $this->api->http_code != 200 )
{
throw new Exception( "Authentification failed! {$this->providerId} returned an error: " . $this->api->lastErrorMessageFromStatus(), 5 );
}

if ( ! isset( $tokz["oauth_token"] ) )
{
throw new Exception( "Authentification failed! {$this->providerId} returned an invalid access token.", 5 );
}

$this->token( "access_token" , $tokz['oauth_token'] );
$this->token( "access_token_secret" , $tokz['oauth_token_secret'] );
parent::initialize();

// set user as logged in
$this->setUserConnected();
// provider api end-points
$this->api->api_base_url = "https://identi.ca/api/";
$this->api->authorize_url = "https://identi.ca/api/oauth/authorize";
$this->api->request_token_url = "https://identi.ca/api/oauth/request_token";
$this->api->access_token_url = "https://identi.ca/api/oauth/access_token";
}

/**
* load the user profile from the IDp api client
*/
function getUserProfile()
{
$response = $this->api->get( 'account/verify_credentials' );
$response = $this->api->get( 'account/verify_credentials.json' );

// check the last HTTP status code returned
if ( $this->api->http_code != 200 )
{
throw new Exception( "User profile request failed! {$this->providerId} returned an error: " . $this->api->lastErrorMessageFromStatus(), 6 );
throw new Exception( "User profile request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ), 6 );
}

if ( ! is_object( $response ) )
Expand All @@ -140,12 +61,12 @@ function getUserProfile()
function getUserContacts( $arguments = ARRAY() )
{
$parameters = array( 'cursor' => '-1' );
$response = $this->api->get( 'friends/ids', $parameters );
$response = $this->api->get( 'friends/ids.json', $parameters );

// check the last HTTP status code returned
if ( $this->api->http_code != 200 )
{
throw new Exception( "User contacts request failed! {$this->providerId} returned an error: " . $this->api->lastErrorMessageFromStatus() );
throw new Exception( "User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
}

if( ! $response ){
Expand All @@ -157,12 +78,12 @@ function getUserContacts( $arguments = ARRAY() )
// donno if users/lookup is supported by identica.. to do
foreach( $response as $item ){
$parameters = array( 'user_id' => $item );
$responseud = $this->api->get( 'users/show', $parameters );
$responseud = $this->api->get( 'users/show.json', $parameters );

// check the last HTTP status code returned
if ( $this->api->http_code != 200 )
{
throw new Exception( "User contacts request failed! {$this->providerId} returned an error: " . $this->api->lastErrorMessageFromStatus() );
throw new Exception( "User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
}

if( $responseud ){
Expand All @@ -189,12 +110,12 @@ function setUserStatus( $arguments = ARRAY() )
$status = $arguments[0]; // status content

$parameters = array( 'status' => $status );
$response = $this->api->post( 'statuses/update', $parameters );
$response = $this->api->post( 'statuses/update.json', $parameters );

// check the last HTTP status code returned
if ( $this->api->http_code != 200 )
{
throw new Exception( "Update user status update failed! {$this->providerId} returned an error: " . $this->api->lastErrorMessageFromStatus() );
throw new Exception( "Update user status update failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
}
}

Expand All @@ -206,16 +127,16 @@ function setUserStatus( $arguments = ARRAY() )
function getUserActivity( $arguments = ARRAY() )
{
if( isset( $arguments[0] ) && $arguments[0] == "me" ){
$response = $this->api->get( 'statuses/user_timeline' );
$response = $this->api->get( 'statuses/user_timeline.json' );
}
else{
$response = $this->api->get( 'statuses/home_timeline' );
$response = $this->api->get( 'statuses/home_timeline.json' );
}

// check the last HTTP status code returned
if ( $this->api->http_code != 200 )
{
throw new Exception( "User activity stream request failed! {$this->providerId} returned an error: " . $this->api->lastErrorMessageFromStatus() );
throw new Exception( "User activity stream request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
}

if( ! $response ){
Expand Down

This file was deleted.

36 changes: 16 additions & 20 deletions additional-providers/hybridauth-github/Providers/GitHub.php
@@ -1,37 +1,33 @@
<?php
/**
/*!
* HybridAuth
*
* A Social-Sign-On PHP Library for authentication through identity providers like Facebook,
* Twitter, Google, Yahoo, LinkedIn, MySpace, Windows Live, Tumblr, Friendster, OpenID, PayPal,
* Vimeo, Foursquare, AOL, Gowalla, and others.
*
* Copyright (c) 2009-2011 (http://hybridauth.sourceforge.net)
*/
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
*/

/**
* Hybrid_Providers_GitHub
*/
class Hybrid_Providers_GitHub extends Hybrid_Providers_Protocols_OAuth2
class Hybrid_Providers_GitHub extends Hybrid_Provider_Model_OAuth2
{
// default permissions
// (no scope) => public read-only access (includes public user profile info, public repo info, and gists).
public $scope = "";

/**
/**
* IDp wrappers initializer
*/
function initialize()
{
parent::initialize();

// Provider apis end-points
// Provider api end-points
$this->api->api_base_url = "https://api.github.com/";
$this->api->authorize_url = "https://github.com/login/oauth/authorize";
$this->api->token_url = "https://github.com/login/oauth/access_token";
}

/**
/**
* load the user profile from the IDp api client
*/
function getUserProfile()
Expand All @@ -42,14 +38,14 @@ function getUserProfile()
throw new Exception( "User profile request failed! {$this->providerId} returned an invalide response.", 6 );
}

$this->user->profile->identifier = @ $data->id;
$this->user->profile->displayName = @ $data->name;
$this->user->profile->description = @ $data->bio;
$this->user->profile->photoURL = @ $data->avatar_url;
$this->user->profile->profileURL = @ $data->html_url;
$this->user->profile->email = @ $data->email;
$this->user->profile->webSiteURL = @ $data->blog;
$this->user->profile->region = @ $data->location;
$this->user->profile->identifier = @ $data->id;
$this->user->profile->displayName = @ $data->name;
$this->user->profile->description = @ $data->bio;
$this->user->profile->photoURL = @ $data->avatar_url;
$this->user->profile->profileURL = @ $data->html_url;
$this->user->profile->email = @ $data->email;
$this->user->profile->webSiteURL = @ $data->blog;
$this->user->profile->region = @ $data->location;

if( ! $this->user->profile->displayName ){
$this->user->profile->displayName = @ $data->login;
Expand Down
10 changes: 3 additions & 7 deletions additional-providers/hybridauth-gowalla/Providers/Gowalla.php
@@ -1,12 +1,8 @@
<?php
/**
/*!
* HybridAuth
*
* A Social-Sign-On PHP Library for authentication through identity providers like Facebook,
* Twitter, Google, Yahoo, LinkedIn, MySpace, Windows Live, Tumblr, Friendster, OpenID, PayPal,
* Vimeo, Foursquare, AOL, Gowalla, and others.
*
* Copyright (c) 2009-2011 (http://hybridauth.sourceforge.net)
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
*/

/**
Expand Down
10 changes: 3 additions & 7 deletions additional-providers/hybridauth-lastfm/Providers/LastFM.php
@@ -1,12 +1,8 @@
<?php
/**
/*!
* HybridAuth
*
* A Social-Sign-On PHP Library for authentication through identity providers like Facebook,
* Twitter, Google, Yahoo, LinkedIn, MySpace, Windows Live, Tumblr, Friendster, OpenID, PayPal,
* Vimeo, Foursquare, AOL, Gowalla, and others.
*
* Copyright (c) 2009-2011 (http://hybridauth.sourceforge.net)
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
*/

/**
Expand Down
14 changes: 4 additions & 10 deletions additional-providers/hybridauth-paypal/Providers/PayPal.php
@@ -1,20 +1,14 @@
<?php
/**
/*!
* HybridAuth
*
* A Social-Sign-On PHP Library for authentication through identity providers like Facebook,
* Twitter, Google, Yahoo, LinkedIn, MySpace, Windows Live, Tumblr, Friendster, OpenID, PayPal,
* Vimeo, Foursquare, AOL, Gowalla, and others.
*
* Copyright (c) 2009-2011 (http://hybridauth.sourceforge.net)
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
*/

require_once Hybrid_Auth::$config["path_providers"] . "/OpenID.php";

/**
* Hybrid_Providers_PayPal class
*/
class Hybrid_Providers_PayPal extends Hybrid_Providers_OpenID
class Hybrid_Providers_PayPal extends Hybrid_Provider_Model_OpenID
{
var $openidIdentifier = "https://www.paypal.com/webapps/auth/server";
}

0 comments on commit a9d4f53

Please sign in to comment.