等待VirusTotal扫描完成

时间:2019-02-15 06:40:59

标签: php json virus antivirus-integration

我正在使用以下代码将文件上传到Virustotal。这很好,但是在curl完成上传后,Virustotal响应等待分析完成消息,我需要再次访问URL以获得结果。 我如何等待从Virustotal获得结果?请指教

$file_name_with_full_path = realpath("test_uploads/$fileName");
$api_key = getenv('VT_API_KEY') ? getenv('VT_API_KEY') :'mykey';
$cfile = curl_file_create($file_name_with_full_path);

$post = array('apikey' => $api_key,'file'=> $cfile);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.virustotal.com/vtapi/v2/file/scan');
curl_setopt($ch, CURLOPT_POST, True);
curl_setopt($ch, CURLOPT_VERBOSE, 1); // remove this if your not debugging
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); // please compress data
curl_setopt($ch, CURLOPT_USERAGENT, "gzip, My php curl client");
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,True);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

$result=curl_exec ($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print("status = $status_code\n");
if ($status_code == 200) { // OK
  $js = json_decode($result, true);
  print_r($js);
} else {  // Error occured
  print($result);
}
curl_close ($ch);

0 个答案:

没有答案