You can integrate the Grupo Chat script into your existing website and achieve a seamless user experience with Single Sign-On (SSO). You can utilize the Grupo API for SSO requests.
API Request helps you to
- Generate Auto Login URL
- Create User (if account doesn’t exists) & Generate Auto Login URL
Request URL
https://yourgrupowebsiteaddress/api_request/
Request body
Field | Description/Values | Required/Optional |
---|---|---|
api_secret_key | Your Grupo API Secret Key. For API Secret Key, Click on Menu > Select Settings > Select General Settings > Find API Secret Key | Required |
add | login_session | Required |
email_address | The email address of the user | Required |
create_account | Whether to create account if account doesn’t exists [yes|no] | Required |
full_name | The name of the user | Required |
username | Username for the user | Required |
password | Password for the user | Required |
site_role | For Site Role ID : Click on Menu > Select Modules > Select Site Roles > Click on Site Role you Prefer > Select Edit > Find “Identifier” | Optional |
avatarURL | The URL for the user’s avatar image | Optional |
custom_field_[id] | Replace [id] with Custom field ID. For Custom Field ID : Click on Menu > Select Modules > Select Custom Field > Click on Custom Field you Prefer to Add > Select Edit > Find “Identifier”. | Optional |
Response Body
KEY | Description/Values |
---|---|
success | This returns true on success and false on failure. |
error_message | Returns a relevant error message |
error_key | This method returns the error key associated with the error |
Example PHP Code
<?php
//Enter the following values
$grupo_web_address = 'http://yourgrupowebaddress/';
$api_secret_key = 'Your Grupo API Secret Key';
$email_address = 'The email address of the user';
//Details of the account to be created (If account doesn't exist)
$create_account = 'yes'; // Whether to Create Account if not exists [yes|no]
$full_name = 'The name of the user';
$username = 'Username for the user';
$password = 'Password for the user';
$avatar = 'User profile image URL';
$site_role_id = ''; // Optional
$iframe_embed = true; // Whether to embed Grupo using iFrame [true|false]
$iframe_width = '500px';
$iframe_height = '700px';
//Ignore the rest
$post_fields=[
'api_secret_key' => $api_secret_key,
'add' => 'login_session',
'create_account'=> $create_account,
'email_address' => $email_address,
'full_name' => $full_name,
'username' => $username,
'password' => $password,
'avatarURL' => $avatar,
'site_role' => $site_role_id,
];
$api_request_url = rtrim($grupo_web_address, '/').'/'.'api_request/';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $api_request_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $post_fields,
CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0'
));
$response = curl_exec($curl);
curl_close($curl);
if (!empty($response)) {
$response = json_decode($response);
if (!empty($response)) {
if ($response->success) {
if ($iframe_embed) {
echo "<iframe src='".$response->auto_login_url."' width='".$iframe_width."' height='".$iframe_height."' allow='camera;microphone' frameborder=0 allowfullscreen></iframe>";
} else {
header("Location: $response->auto_login_url");
die();
}
} else {
echo $response->error_message;
}
}
}