Skip to content

Commit

Permalink
WSL 2.0.0 + accounts linking #11
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridauth committed Jan 20, 2013
1 parent a735d5e commit bef984a
Show file tree
Hide file tree
Showing 51 changed files with 3,909 additions and 2,450 deletions.
202 changes: 0 additions & 202 deletions assets/js/highcharts.js

This file was deleted.

41 changes: 40 additions & 1 deletion hybridauth/Hybrid/Providers/Steam.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,43 @@
class Hybrid_Providers_Steam extends Hybrid_Provider_Model_OpenID
{
var $openidIdentifier = "http://steamcommunity.com/openid";
}

/**
* finish login step
*/
function loginFinish()
{
parent::loginFinish();

$uid = str_replace( "http://steamcommunity.com/openid/id/", "", $this->user->profile->identifier );

if( $uid ){
$data = @ file_get_contents( "http://steamcommunity.com/profiles/$uid/?xml=1" );

$data = @ new SimpleXMLElement( $data );

if ( ! is_object( $data ) ){
return false;
}

$this->user->profile->displayName = (string) $data->{'steamID'};
$this->user->profile->photoURL = (string) $data->{'avatarMedium'};
$this->user->profile->description = (string) $data->{'summary'};

$realname = (string) $data->{'realname'};

if( $realname ){
$this->user->profile->displayName = $realname;
}

$customURL = (string) $data->{'customURL'};

if( $customURL ){
$this->user->profile->profileURL = "http://steamcommunity.com/id/$customURL/";
}

// restore the user profile
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
}
}
}
246 changes: 20 additions & 226 deletions hybridauth/Hybrid/Providers/Yahoo.php
Original file line number Diff line number Diff line change
@@ -1,237 +1,31 @@
<?php
//!! planned to be replaced Y! openid by the oauth1 adapter soon

/*!
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
*/

/**
* Yahoo OAuth Class
*
* @package HybridAuth providers package
* @author Lukasz Koprowski <azram19@gmail.com>
* @version 0.2
* @license BSD License
*/

/**
* Hybrid_Providers_Yahoo - Yahoo provider adapter based on OAuth1 protocol
*/
class Hybrid_Providers_Yahoo extends Hybrid_Provider_Model_OAuth1
* Hybrid_Providers_Yahoo provider adapter based on OAuth1 protocol
*
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Yahoo.html
*/
class Hybrid_Providers_Yahoo extends Hybrid_Provider_Model_OpenID
{
function initialize()
{
parent::initialize();

// Provider api end-points
$this->api->api_base_url = 'http://social.yahooapis.com/v1/';
$this->api->authorize_url = 'https://api.login.yahoo.com/oauth/v2/request_auth';
$this->api->request_token_url = 'https://api.login.yahoo.com/oauth/v2/get_request_token';
$this->api->access_token_url = 'https://api.login.yahoo.com/oauth/v2/get_token';
}

function getUserProfile()
{
$userId = $this->getCurrentUserId();

$parameters = array();
$parameters['format'] = 'json';

$response = $this->api->get( 'user/' . $userId . '/profile', $parameters );

if ( ! isset( $response->profile ) ){
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
}

$data = $response->profile;

$this->user->profile->identifier = (property_exists($data,'guid'))?$data->guid:"";
$this->user->profile->firstName = (property_exists($data,'givenName'))?$data->givenName:"";
$this->user->profile->lastName = (property_exists($data,'familyName'))?$data->familyName:"";
$this->user->profile->displayName = (property_exists($data,'nickname'))?trim( $data->nickname ):"";
$this->user->profile->profileURL = (property_exists($data,'profileUrl'))?$data->profileUrl:"";
$this->user->profile->gender = (property_exists($data,'gender'))?$data->gender:"";

if( $this->user->profile->gender == "F" ){
$this->user->profile->gender = "female";
}

if( $this->user->profile->gender == "M" ){
$this->user->profile->gender = "male";
}

if( isset($data->emails) ){
$email = "";
foreach( $data->emails as $v ){
if( isset($v->primary) && $v->primary ) {
$email = (property_exists($v,'handle'))?$v->handle:"";

break;
}
}

$this->user->profile->email = $email;
$this->user->profile->emailVerified = $email;
}

$this->user->profile->age = (property_exists($data,'displayAge'))?$data->displayAge:"";
$this->user->profile->photoURL = (property_exists($data,'image'))?$data->image->imageUrl:"";

$this->user->profile->address = (property_exists($data,'location'))?$data->location:"";
$this->user->profile->language = (property_exists($data,'lang'))?$data->lang:"";

return $this->user->profile;
}

/**
* load the user contacts
*/
function getUserContacts()
{
$userId = $this->getCurrentUserId();

$parameters = array();
$parameters['format'] = 'json';
$parameters['count'] = 'max';

$response = $this->api->get('user/' . $userId . '/contacts', $parameters);

if ( $this->api->http_code != 200 )
{
throw new Exception( 'User contacts request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus( $this->api->http_code ) );
}

if ( !$response->contacts->contact && ( $response->errcode != 0 ) )
{
return array();
}

$contacts = array();

foreach( $response->contacts->contact as $item ) {
$uc = new Hybrid_User_Contact();

$uc->identifier = $this->selectGUID( $item );
$uc->email = $this->selectEmail( $item->fields );
$uc->displayName = $this->selectName( $item->fields );
$uc->photoURL = $this->selectPhoto( $item->fields );

$contacts[] = $uc;
}

return $contacts;
}

/**
* return the user activity stream
*/
function getUserActivity( $stream )
{
$userId = $this->getCurrentUserId();

$parameters = array();
$parameters['format'] = 'json';
$parameters['count'] = 'max';

$response = $this->api->get('user/' . $userId . '/updates', $parameters);

if( ! $response->updates || $this->api->http_code != 200 )
{
throw new Exception( 'User activity request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus( $this->api->http_code ) );
}

$activities = array();

foreach( $response->updates as $item ){
$ua = new Hybrid_User_Activity();

$ua->id = (property_exists($item,'collectionID'))?$item->collectionID:"";
$ua->date = (property_exists($item,'lastUpdated'))?$item->lastUpdated:"";
$ua->text = (property_exists($item,'loc_longForm'))?$item->loc_longForm:"";

$ua->user->identifier = (property_exists($item,'profile_guid'))?$item->profile_guid:"";
$ua->user->displayName = (property_exists($item,'profile_nickname'))?$item->profile_nickname:"";
$ua->user->profileURL = (property_exists($item,'profile_profileUrl'))?$item->profile_profileUrl:"";
$ua->user->photoURL = (property_exists($item,'profile_displayImage'))?$item->profile_displayImage:"";

$activities[] = $ua;
}

if( $stream == "me" ){
$userId = $this->getCurrentUserId();
$my_activities = array();

foreach( $activities as $a ){
if( $a->user->identifier == $userId ){
$my_activities[] = $a;
}
}

return $my_activities;
}

return $activities;
}

//--

function select($vs, $t)
{
foreach( $vs as $v ){
if( $v->type == $t ) {
return $v;
}
}

return NULL;
}

function selectGUID( $v )
{
return (property_exists($v,'id'))?$v->id:"";
}

function selectName( $v )
{
$s = $this->select($v, 'name');

if( ! $s ){
$s = $this->select($v, 'nickname');
return ($s)?$s->value:"";
} else {
return ($s)?$s->value->givenName . " " . $s->value->familyName:"";
}
}

function selectNickame( $v )
{
$s = $this->select($v, 'nickname');
return ($s)?$s:"";
}

function selectPhoto( $v )
{
$s = $this->select($v, 'guid');
return ($s)?(property_exists($s,'image')):"";
}

function selectEmail( $v )
{
$s = $this->select($v, 'email');
return ($s)?$s->value:"";
}

public function getCurrentUserId()
{
$parameters = array();
$parameters['format'] = 'json';
var $openidIdentifier = "https://open.login.yahooapis.com/openid20/www.yahoo.com/xrds";

$response = $this->api->get( 'me/guid', $parameters );
/**
* finish login step
*/
function loginFinish()
{
parent::loginFinish();

if ( ! isset( $response->guid->value ) ){
throw new Exception( "User id request failed! {$this->providerId} returned an invalid response." );
}
$this->user->profile->emailVerified = $this->user->profile->email;

return $response->guid->value;
}
// restore the user profile
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
}
}
Loading

0 comments on commit bef984a

Please sign in to comment.