/API / DeleteSubscribe. Unsubscribe a Contact from a Group
Content
1 Parameters Transferred in the Query
3 Example of Changing the Contact Data in PHP
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 with Zapier.
You can unsubscribe contacts from a group in your InfluencerSoft account by requesting a query to the API service using software methods.
The query is sent by the POST method in the URL encode format to the address: http://username.influencersoft.com/api/DeleteSubscribe where the username is the login of the user in the system, as well as their domain of the third level in the InfluencerSoft service.
Parameters Transferred in the Query
- lead_email is the email of the unsubscribing contact
- rass_name is the unsubscribing client contacts group identifier
Both fields are required.
How Does It Work?
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.
The activation confirmation email will not be received after re-subscribing.
Example of Changing the Contact Data in PHP
In the example, we unsubscribe the user with the lead@email.com email from the “super” group. 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 Influencersoft 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' => 'lead@email.com', // user’s email 'rass_name' => 'super' // unsubscribing group ); // Forming the hash to the transmitted data. $send_data['hash'] = GetHash($send_data, $user_rs); // Forming the hash to the transmitted data. $resp = json_decode(Send('http://username.justclick.io/api/DeleteSubscribe', $send_data)); //Checking the service response. if(!CheckHash($resp, $user_rs)){ echo "Error! The response hash is not valid!" ; exit; } if($resp->error_code == 0) echo "The user unsubscribed the group {$send_data['rid[0]']}. Service resonse: {$resp->error_code}"; 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 }
Articles
The Script Notification When Unsubscribing from Your Newsletters
GetLeadGroupStatuses. Receiving a List of All Contact Groups with a Subscription Status
AddLeadToGroup. Adding a Contact to a Group
UpdateSubscriberData. Editing the Existing Contact’s Data
GetLeadGroups. Receiving a List of All Contact Groups
GetAllGroups. Receiving a List of all Contact Groups from the Account
Comments
0 comments
Please sign in to leave a comment.