Hi all, I am using the picture field in contacts to store an avatar image for my contacts. I want to be able to dowload this page via the api so I can store it on a website that the contacts use. i read the following page
and the code
//Get An Attachment on a Note
$url = $instance_url . "/Notes/{$noteRecord->id}/file/filename";
$curl_request = curl_init($url);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
//Return Headers
curl_setopt($curl_request, CURLOPT_HEADER, true);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
//DO NOT set Content Type Header to JSON
curl_setopt($curl_request, CURLOPT_HTTPHEADER, array(
"oauth-token: {$oauth_token}"
));
//execute request
$curl_response = curl_exec($curl_request);
//Get Return Headers
$header_size = curl_getinfo($curl_request,CURLINFO_HEADER_SIZE);
$headers = substr($curl_response, 0, $header_size);
//Outputting the file contents
echo 'File saved to download.txt';
$file = substr($curl_response, $header_size);
file_put_contents('download.txt', $file);
curl_close($curl_request);
but this code assumes the file name is download.txt, how do I get the filename first
in my example i can get the file info using {{localURL}}Contacts/0e05f7b4-9993-11e9-af70-06a63d65978a/file/ which returns
{
"picture": {
"content-type": "image/png",
"content-length": 53843,
"name": "ae2c25a0-4ad3-11ea-bbf1-080027633d6c",
"width": 1611,
"height": 1612,
"uri": "rest/v11/Contacts/0e05f7b4-9993-11e9-af70-06a63d65978a/file/picture"
}
}
but i dont get back the file name to then use in the curl request