To integrate with other services and applications, we recommend setting up integration via Zapier.
You will be able to transfer data between services without the help of programmers.
Learn more about integration via Zapier

This method replaces the previous one, GetLeadGroups.

You can get the contact groups list requesting a query to the API service by software methods using their email. In response, your system will receive an array. There for each group will be transferred:

  • Group ID;
  • Group name;
  • Contact status in this group;
  • Time of subscribing to this group.

The query is requested by the POST method in the URLencode format to the address: https://username.justclick.io/api/GetLeadGroupStatuses

Where username is the login of the user in the system, as well as their domain of the third level in the JustClick service.

Parameters Transferred in the Query

The one and only required field is the email field, i.e. the subscriber’s email that you need to get the current groups list.

How Does It Work

You transfer the client email to the GetLeadGroupStatuses API function. Your system will receive the result of the function-performing and an array with subscription groups in the result variable in response.

The groups array will look as follows:

Array
(
	[0] => stdClass Object
		(
			[rass_name] => Group 1 ID
			[rass_title] => Group 1 Name
			[rass_status] => Group 1 Subscription Status
			[subscription_time] => Group 1 Subscription Time
		)
 
	[1] => stdClass Object
		(
			[rass_name] => Group 2 ID
			[rass_title] => Group 2 Name
			[rass_status] => Group 2 Subscription Status
			[subscription_time] => Group 2 Subscription Time
		)
 
	[2] => stdClass Object
		(
			[rass_name] => Group 3 ID
			[rass_title] => Group 3 Name
			[rass_status] => Group 3 Subscription Status
			[subscription_time] => Group 3 Subscription Time
		)
)

The response is coded in JSON format. For more details, see the “API Service Responses”.

Possible subscription statuses:

STATUS_WAIT – The activation is pending.

STATUS_SUBSCRIBE – The subscription is signed / activated.

STATUS_UNSUBSCRIBE – The client unsubscribed.

STATUS_UNSUBSCRIBE_BY_SERVICE – The client unsubscribed from service.

STATUS_INVALID_EMAIL – The email doesn’t exist.

Example of Getting a Subscription Groups List in PHP

We get subscription groups for the user with the email [email protected] in the example. Your login to the system is “username”.

GetHash Function forms the hash to the transferred data.

CheckHash Function checks the hash to the service response.

// Login to the JustClick system.
 $user_rs['user_id'] = 'username';
  //The key for forming a hash. See API section (the link in the right bottom corner of the personal account).
 $user_rs['user_rps_key'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
 
 // Forming the data array for transferring to the API.
$send_data['email'] = '[email protected]'; // Client email, that we get the subscription groups list from.

// Forming the hash to the transmitted data.
$send_data['hash'] = GetHash($send_data, $user_rs);

// Calling the GetLeadGroupStatuses function and decoding the received data.
$resp = json_decode(Send('https://username.justclick.io/api/GetLeadGroupStatuses', $send_data));

// Checking the service response.
if(!CheckHash($resp, $user_rs)){
	echo "Error! The response hash is not true!"; print_r($resp);
	exit;
}

if($resp->error_code == 0){
echo “Group List”;
print_r($resp->result);
}
else
	echo "Error code:{$resp->error_code} - description: {$resp->error_text}";

// =========== Functions of sending, receiving and processing a response ============

// Sending the query to the API service
function Send($url, $data)
{
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // outputting the response to the variable.

	$res = curl_exec($ch);

	curl_close($ch);
	return $res;
}

// Forming the transferred to the API data hash.
function GetHash($params, $user_rs) {
	$params = http_build_query($params);
	$user_id = $user_rs['user_id'];
	$secret = $user_rs['user_rps_key'];
	$params = "$params::$user_id::$secret";
	return md5($params);
}

// Checking the received response hash.
function CheckHash($resp, $user_rs) {
	$secret = $user_rs['user_rps_key'];
	$code = $resp->error_code;
	$text = $resp->error_text;
	$hash = md5("$code::$text::$secret");
	if($hash == $resp->hash)
		return true; // the hash is correct.
	else
		return false; // the hash is not correct.
}

Rate article

1 star2 stars3 stars4 stars5 stars (1 votes, avr.: 5.00 / 5)
Loading...