Content
You will be able to transfer data between services without the help of programmers.
Learn more about integration via Zapier
You can change the existing contact data requesting a query to the API service using software methods. You can change the name of the contact, the telephone number and the city of residence.
You can change each contact data once using the function.
The query is sent by the POST method in the URLencode format to the address: https://username.justclick.io/api/UpdateSubscriberData.
Where username is the login of the user to the system, as well as their domain of the third level in the JustClick service.
Parameters Transferred in the Query
- lead_email is the email of the existing contact (required);
- lead_name is the new name of the contact after the query is made (optional);
- lead_phone is the telephone number that will be replaced by the one already specified (not necessarily);
- lead_city is the city of contact (optional);
- lead_tags is the tag (or tags) of contact (optional).
The lead_email field is the only required field. The other fields are up to you. If the field is turned down, the user data in this field remain unchanged.
How Does It Work?
You transfer the contact’s email and new data to the UpdateSubscriberData API function to replace the old ones.
Your system will receive the result of the function in response. The response is coded in JSON format. For more details, see the “API Service Responses”.
Example of Changing the Contact Data in PHP
In the example, we change the contact data with the email “[email protected]”. Login to the system is “username”.
Function GetHash forms the hash to the transferred data.
Function CheckHash checks the hash of 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 bottom right corner of the personal account). $user_rs['user_rps_key'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; // Forming the data array for transferring to the API. $send_data = array( 'lead_email' => '[email protected]', // the existing subscriber name. 'lead_name' => 'John', // the replacement name. 'lead_phone' => '+18000000000', // new telephone number. 'lead_city' => 'Los Angeles', // city of residence. 'lead_tags' => 'tag1,tag2,tag3', // subscriber tags. ); // Forming the hash to the transmitted data. $send_data['hash'] = GetHash($send_data, $user_rs); // Calling the UpdateSubscriberData function in the API and decoding the received data. $resp = json_decode(Send('https://username.justclick.io/api/UpdateSubscriberData', $send_data)); // Checking the service response. if(!CheckHash($resp, $user_rs)){ echo "Error! The response hash is not valid!"; print_r($resp); exit; } if($resp->error_code == 0) echo "The subscriber data are updated: {$resp->error_text}"; 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. }