Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SteemConnect provider integration #917

Merged
merged 1 commit into from Feb 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/providers.md
Expand Up @@ -46,6 +46,7 @@ TwitchTV | OAuth2 | [X] | [X] |
Authentiq | OAuth2 | [X] | [X] | | |
Spotify | OAuth2 | [X] | [X] | | |
WeChat | OAuth2 | [X] | [X] | | |
SteemConnect | OAuth2 | [X] | [X] | | |

{% include callout.html content="Some providers such as Google and Yahoo may use multiple protocols for their APIs and as naming convention we append the protocol's name to the adapter's (Often the case with OpenID adapters as those might be subject to removal by providers in near future due to deprecation of the OpenID protocol)." type="default" %}

Expand Down
70 changes: 70 additions & 0 deletions src/Provider/SteemConnect.php
@@ -0,0 +1,70 @@
<?php
/*!
* Hybridauth
* https://hybridauth.github.io | https://github.com/hybridauth/hybridauth
* (c) 2017 Hybridauth authors | https://hybridauth.github.io/license.html
*/

namespace Hybridauth\Provider;

use Hybridauth\Adapter\OAuth2;
use Hybridauth\Exception\UnexpectedApiResponseException;
use Hybridauth\Data;
use Hybridauth\User;

/**
* Instagram OAuth2 provider adapter.
*/
class SteemConnect extends OAuth2
{
/**
* {@inheritdoc}
*/
protected $scope = 'login,vote';

/**
* {@inheritdoc}
*/
protected $apiBaseUrl = 'https://v2.steemconnect.com/';

/**
* {@inheritdoc}
*/
protected $authorizeUrl = 'https://v2.steemconnect.com/oauth2/authorize';

/**
* {@inheritdoc}
*/
protected $accessTokenUrl = 'https://v2.steemconnect.com/api/oauth2/token';

/**
* {@inheritdoc}
*/
protected $apiDocumentation = 'https://steemconnect.com/';

/**
* {@inheritdoc}
*/
public function getUserProfile()
{
$response = $this->apiRequest('api/me');

$data = new Data\Collection($response);

if (! $data->exists('result')) {
throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
}

$userProfile = new User\Profile();

$data = $data->filter('result');

$userProfile->identifier = $data->get('id');
$userProfile->description = $data->get('about');
$userProfile->photoURL = $data->get('profile_image');
$userProfile->webSiteURL = $data->get('website');
$userProfile->displayName = $data->get('name');

return $userProfile;
}
}