The following is a simple example of how to retrieve a file 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
For details on how to get a list of client files see this article:
https://hubsolv.zendesk.com/hc/en-us/articles/115002159554
<?php
// Your Username and Password
$username = 'your-username';
$password = 'your-password';
// The id of the file you want to get, retrieve a list using the 'files' method
$fileid = 12;
$params = array();
$params['HUBSOLV-API-KEY'] = 'your-api-key';
$params['id'] = $fileid;
// 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/file/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);
// Write buffer to a file on disk
file_put_contents ("/var/files/filename", $buffer);
?>
Comments
0 comments
Please sign in to leave a comment.