The following is a simple example of how to retrieve a client record from HubSolv using PHP & cURL.
The script will capture an api-access-code, and clientid, that was posted to it from HubSolv and use the access code to make a request to HubSolv to retrieve all the data relating to that client record.
For details on how to post the access code to your system initially see this article:
https://hubsolv.zendesk.com/hc/en-us/articles/115002159254
<?php
// Your Username and Password
$username = 'your-username';
$password = 'your-password';
// The API Access code - Either captured from a post to this script
// or captured elsewhere and stored
$api-access-code = $_POST['api-access-code'];
// The client id this relates to, you don't need this to retrieve the object
// but you may wish to store it in your own system for cross reference
// You will also need it pull back client files
$hubsolv_clientid = $_POST['clientid'];
$params = array();
$params['HUBSOLV-API-KEY'] = 'your-api-key';
$params['api-access-code'] = $api-access-code;
$url = 'https://yoursubdomain.hubsolv.com/api/client/format/json'; $query_string = http_build_query($params);
$full_url = $url . '?' . $query_string;
/* creating a client record */
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $full_url);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERPWD, $username . ':' . $password);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
$result = json_decode($buffer);
if($result->status == "success_get") {
// do something with the data
}
else {
// deal with error
}
?>
Expected Response
"status": "success_get",
"client": {
"has_life_policies": false,
"not_has_life_policies": true,
"partner_has_life_policies": false,
"partner_not_has_life_policies": true,
"endowments": false,
"partner_endowments": false,
"has_endowments": false,
"not_has_endowments": true,
"partner_has_endowments": false,
"partner_not_has_endowments": true,
"assets": false,
"id": "69688",
"title": null,
"firstname": "Test Client",
"middlename": null,
"lastname": "yeea",
"othername": null,
"pob": null,
"dob": null,
"gender": null,
"phone_home": "00000000",
"phone_mobile": "00000000",
"phone_work": null,
"email": "sean@hubsolv.com",
"time_to_contact": null,
"contact_method": null,
"marital_status": null,
"partner": "0",
"dependants": null,
"non_dependants": null,
"partner_title": null,
"partner_firstname": null,
"partner_middlename": null,
"partner_lastname": null,
"partner_othername": null,
"partner_pob": null,
"partner_dob": null,
"partner_phone_home": null,
"partner_phone_mobile": null,
"partner_phone_work": null,
"partner_email": null,
"employment_status": null,
"address_1": null,
"address_2": null,
"address_3": null,
"town": null,
"county": null,
"postcode": null,
"country": null,
"time_at_address_year": null,
"time_at_address_month": null,
"occupation": null,
"vulnerability_rating": null,
"vulnerability_type": null,
"vulnerability_notes": null,
"large_font": "0",
"authority_share": "0",
"authority_store": "0",
"third_party_consent": "0",
"third_party_title": null,
"third_party_firstname": null,
"third_party_lastname": null,
"third_party_time_to_contact": null,
"third_party_relationship": null,
"third_party_notes": null,
"third_party_email": null,
"third_party_phone": null,
"third_party_address_1": null,
"third_party_address_2": null,
"third_party_address_3": null,
"third_party_town": null,
"third_party_county": null,
"third_party_postcode": null,
"third_party_country": null,
"source": "user",
"created_userid": "1",
"deleted": "0",
"date_created": "1593702067",
"date_modified": "1593785328",
"lead_source": "",
"lead_generator": "",
"lead_urn": null,
"lead_type": "",
"import_reference": null,
}
}
Comments
0 comments
Please sign in to leave a comment.