Как настроить провайдер steam для HybridAuth ?

Добрый день, после настройки в админке steam по примеру остальных провайдеров получаю такую картину — при авторизации на сайте: Вы авторизованы как steamcommunity.com/openid/id/765611979800
У steam обновлялся api
Заглянул сюда core/components/hybridauth/model/hybridauth/lib/Providers/Steam.php
и сюда
github.com/hybridauth/hybridauth/blob/master/additional-providers/hybridauth-steam/Providers/Steam.php
Возник вопрос, я что то не так делаю? или файл core/components/hybridauth/model/hybridauth/lib/Providers/Steam.php нужно менять?
Jury
16 августа 2015, 10:26
modx.pro
1
2 268
0

Комментарии: 2

Jury
17 августа 2015, 09:26
0
Решился вопрос так, если кому то нужно

<?php
/*!
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* © 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
 * Hybrid_Providers_Steam provider adapter based on OpenID protocol
 *
 * http://hybridauth.sourceforge.net/userguide/IDProvider_info_Steam.html
 *
 * This class has been entirely reworked for the new Steam API (http://steamcommunity.com/dev)
 */
class Hybrid_Providers_Steam extends Hybrid_Provider_Model_OpenID
{
    var $openidIdentifier = "http://steamcommunity.com/openid";
    function loginFinish()
    {
        parent::loginFinish();
        $this->user->profile->identifier = str_ireplace("http://steamcommunity.com/openid/id/",
            "", $this->user->profile->identifier);
        if (!$this->user->profile->identifier) {
            throw new Exception("Authentication failed! {$this->providerId} returned an invalid user ID.", 5);
        }
        // If API key is not provided, use legacy API methods
        if (!empty($this->config['keys']['key'])) {
            $this->getUserProfileWebAPI($this->config['keys']['key']);
        } else {
            $this->getUserProfileLegacyAPI();
        }
        Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
    }
    function getUserProfileWebAPI($apiKey)
    {
        $apiUrl = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key='
            . $apiKey . '&steamids=' . $this->user->profile->identifier;
        $data = @file_get_contents($apiUrl);
        $data = json_decode($data);
        if (!is_object($data) || !isset($data->response->players[0])) {
            return false;
        }
        // Get the first index in 'players' array
        $data = $data->response->players[0];
        $this->user->profile->displayName = property_exists($data, 'personaname') ? $data->personaname : '';
        $this->user->profile->firstName = property_exists($data, 'realname') ? $data->personaname."" : '';
        $this->user->profile->photoURL = property_exists($data, 'avatarfull') ? $data->avatarfull : '';
        $this->user->profile->profileURL = property_exists($data, 'profileurl') ? $data->profileurl : '';
        $this->user->profile->country = property_exists($data, 'loccountrycode') ? $data->loccountrycode : '666';
		$this->user->profile->profileURL		=	property_exists($data, 'customURL') ? "http://steamcommunity.com/id/{$data->customURL}/" : "http://steamcommunity.com/profiles/{$this->user->profile->identifier}/";
		$this->user->profile->webSiteURL		=	property_exists($data, 'customURL') ? "http://steamcommunity.com/id/{$data->customURL}/" : "http://steamcommunity.com/profiles/{$this->user->profile->identifier}/";
    }
    function getUserProfileLegacyAPI()
    {
        $apiUrl = 'http://steamcommunity.com/profiles/' . $this->user->profile->identifier . '/?xml=1';
        $data = @file_get_contents($apiUrl);
        $data = @ new SimpleXMLElement($data);
        if (!is_object($data)) {
            return false;
        }
		# store the user profile.  
		//$this->user->profile->identifier		=	"";
		$this->user->profile->profileURL		=	property_exists($data, 'customURL') ? "http://steamcommunity.com/id/{$data->customURL}/" : "http://steamcommunity.com/profiles/{$this->user->profile->identifier}/";
		$this->user->profile->webSiteURL		=	property_exists($data, 'customURL') ? "http://steamcommunity.com/id/{$data->customURL}/" : "http://steamcommunity.com/profiles/{$this->user->profile->identifier}/";
		$this->user->profile->photoURL			=	property_exists($data, 'avatarFull') ? (string)$data->avatarFull : '';
		$this->user->profile->displayName		=	property_exists($data, 'steamID') ? (string)$data->steamID : '';
		$this->user->profile->description		=	property_exists($data, 'summary') ? (string)$data->summary : '';
		$this->user->profile->firstName			=	property_exists($data, 'realname') ? (string)$data->realname."11" : '';
		$this->user->profile->lastName			=	"";
		$this->user->profile->gender			=	"";
		$this->user->profile->language			=	"";
		$this->user->profile->age				=	"";
		$this->user->profile->birthDay			=	"";
		$this->user->profile->birthMonth		=	"";
		$this->user->profile->birthYear			=	"";
		$this->user->profile->email				=	"";
		$this->user->profile->emailVerified	    =	"";
		$this->user->profile->phone				=	"";
		$this->user->profile->address			=	"";
		$this->user->profile->country			=	"";
		$this->user->profile->region			=	property_exists($data, 'location') ? (string)$data->location : '';
		$this->user->profile->city				=	"";
		$this->user->profile->zip				=	"";
    }
}
    Николай Загумённов
    11 октября 2016, 15:54
    0
    Понадобилось привязать WarGaming ID
    Нашел на gitHub
    <?php
    /*!
    * HybridAuth
    * http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
    *  © 2009-2015 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
    */
    /**
     * Hybrid_Providers_WarGaming
     */
    class Hybrid_Providers_WarGaming extends Hybrid_Provider_Model_OpenID
    {
      var $openidIdentifier = "http://ru.wargaming.net/id/";
      /**
       * finish login step
       */
      function loginFinish()
      {
        parent::loginFinish();
        $this->user->profile->profileURL = $this->user->profile->identifier;
        // https://ru.wargaming.net/id/5069690-Steel_Master/
        $this->user->profile->identifier = preg_replace( '/^[^0-9]+([0-9]+)-.+$/', '$1', $this->user->profile->identifier );
        // restore the user profile
        Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
      }
    }
      Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
      2