composer require justauthme/php-sdk
<?php
use JustAuthMe\SDK\JamSdk;
/*
* Params:
* @string app_id The app_id provided by the developers console
* @string redirect_url The callback URL your provided at your app creation
* @string api_secret The secret delivered to you by the developers console
*/
$jamSdk = new JamSdk($app_id, $redirect_url, $api_secret);
Please see the official button repository for complete documentation: https://github.com/justauthme/button
The generateDefaultButtonHtml
method take 2 parameters: lang
and size
.
You can chose between fr
and en
languages, and between x1
, x2
and x4
sizes.
Default lang
is en
, default size
is x2
.
<?php /* DEPRECATED */ echo $jamSdk->generateDefaultButtonHtml($lang, $size); ?>
<a href="<?php echo $jamSdk->generateLoginUrl(); ?>">Login with JustAuthMe</a>
<?php
use JustAuthMe\SDK\JamSdk;
if (isset($_GET['access_token'])) {
// The expected access_token is present
$jamSdk = new JamSdk($app_id, $redirect_url, $api_secret);
try {
$user_infos = $jamSdk->getUserInfos($_GET['access_token']);
/*
* Everything is fine, you can now register or login the user,
* depending on the presence in your Database of
* the provided $user_infos->jam_id
*/
} catch (Exception $e) {
error_log($e->getMessage());
// Login fail, you should redirect to an error page
}
} else {
/*
* The callback URL wasn't called with the correct parameter
* you should redirect to an error page
*/
}
For a complete documentation of this SDK, please see DOCUMENTATION.md
If anything goes wrong, feel free to open an issue on this repo, we will be pleased to help you.