The following is a simple example of how to retrieve a list of client files from HubSolv using PHP & cURL.
The script will use the clientid, that was posted to it from HubSolv (along with 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 and client id 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
$hubsolv_clientid = $_POST['clientid'];
$params = array();
$params['HUBSOLV-API-KEY'] = 'your-api-key';
$params['id'] = $hubsolv_clientid;
// You can optionally pass in a folder id or don't pass this to get all files
$params['folderid'] = 3;
$url = 'https://yoursubdomain.hubsolv.com/api/files/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
}
?>
Comments
0 comments
Please sign in to leave a comment.