1. Go to this page and download the library: Download hernandev/oauth2-sc2 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hernandev / oauth2-sc2 example snippets
use SteemConnect\OAuth2\Config\Config;
// creates the configuration object:
$config = new Config('your.app', 'your-long-secret-id-here-keep-it-secret');
// set the scopes you want.
$config->setScopes([
'login', 'vote', 'comment', 'comment_delete'
]);
// set the return / callback URL.
$config->setReturnUrl('https://my-steem-app-is-awesome.com/login/return');
use SteemConnect\OAuth2\Provider\Provider;
// first, we create a provider instance, passing the configuration needed:
$provider = new Provider($config);
// get the URL string that you will redirect to.
$provider->getAuthorizationUrl()
// just call the parse return URL and this library will automatically exchange the access code by the actual token:
$token = $provider->parseReturn();
// gets the actual token that will be used on requests.
$token->getToken();
// gets the expiration date, so you know the token is no longer valid.
$token->getExpires();
// gets the refresh token, which may be used to issue a new token, if the offline scope was requested.
$token->getRefreshToken();
// gets the standard ID for the account authorizing your app, it means, this field retrieves the account @username
$token->getResourceOwnerId();
// encode the AccessToken instance into a JSON string.
$tokenJson = $provider->encodeToken($token);
// decode the JSON string token back into a AccessToken instance.
$token = $provider->decodeToken($tokenJson);
// get a new token from the existing / expired one.
$newToken = $provider->refreshToken($token);
// get a new AccessToken using the refresh token string.
$token = $provider->refreshTokenString($refreshTokenString);
// gets the resource owner instance.
$owner = $provider->getResourceOwner($token);
// now you can use any key you may see on steemd.com directly on that $owner object!!!
$owner->profile_json;
$owner->balance;
$owner->reputation;
// and so on...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.