/API / GetAllGroups. Receiving a List of all Contact Groups from the Account
Content
1 Parameters Transferred in the Query
3 Example of Getting a Subscription Groups List 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 via Zapier.
You can get all the contact groups list from your account by requesting a query to the API service through API methods using their emails. In response, your system will receive an array. Therefore, each group will be transferred to a group ID and given a group name. Auto-groups will not be included in this list.
The query is sent by the POST method in the URL-encode format to the address http://username.influencersoft.com/api/GetAllGroups 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
There are no parameters for this function. The only parameter transferred is the query hash, as for all other queries.
How Does It Work?
You call GetAllGroups API function.
Your system will receive the result of the function performing the array with subscription groups in the result variable in the response.
The groups array will look as follows:
$resp->result = Array ( [0] => array ( [rass_name] => Group 1 ID [rass_title] => Group 1 Name ) [1] => array ( [rass_name] => Group 2 ID [rass_title] => Group 2 Name ) [2] => array ( [rass_name] => Group 3 ID [rass_title] => Group 3 Name ) )
The response is coded in JSON format. For more details, see the “API Service Responses”.
Example of Getting a Subscription Groups List in PHP
GetHash Function forms the hash to the transferred data.
CheckHash Function checks the hash to 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 hash to the transmitted data $send_data['hash'] = GetHash(null, $user_rs); // Calling the GetAllGroups on the client's mail function and decoding the received data $resp = json_decode(Send('http://username.influencersoft.com/api/GetAllGroups', $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. }
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
DeleteSubscribe. Unsubscribe a Contact from a Group
GetLeadGroups. Receiving a List of All Contact Groups
Comments
0 comments
Please sign in to leave a comment.