I wrote this code to integrate with filepicker.io, it takes the URL of the file and gets the header information:
$info = curl_init() or die('error 1');
curl_setopt($info, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($info, CURLOPT_PORT , 8089);
curl_setopt($info, CURLOPT_URL, $url);
curl_setopt($info, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($info, CURLOPT_NOBODY, true);
//curl_setopt($info, CURLOPT_SSL_VERIFYPEER, 0);
curl_exec($info);
if(!curl_errno($info)){
$response = curl_getinfo($info);
echo "<pre>";
echo var_dump($response);
echo "</pre>";
}else{
echo "error!";
echo "<br>" . curl_error($info);
}
And here is a response:
array(26) {
["url"]=>
string(55) "https://www.filepicker.io/api/file/CjDfxG0WSmGiY3O2eKDE"
["content_type"]=>
string(9) "image/png"
["http_code"]=>
int(200)
["header_size"]=>
int(840)
["request_size"]=>
int(86)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(2.805141)
["namelookup_time"]=>
float(0.442366)
["connect_time"]=>
float(0.46781)
["pretransfer_time"]=>
float(0.873621)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(965985)
["upload_content_length"]=>
float(0)
["starttransfer_time"]=>
float(2.805054)
["redirect_time"]=>
float(0)
["certinfo"]=>
array(0) {
}
["primary_ip"]=>
string(11) "79.125.4.68"
["primary_port"]=>
int(443)
["local_ip"]=>
string(11) "192.168.0.9"
["local_port"]=>
int(51414)
["redirect_url"]=>
string(0) ""
}
There is one massive thing missing - the file name, as I understand it that should be returned with the header or do I have to make a specific request for it. The filename is masked in the URL so I cannot use that.
Any suggestions would be great!