Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Commit

Permalink
dealing w/ response code, catching and handling of a network error
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzySoft committed Mar 15, 2017
1 parent 776e370 commit b75ab36
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions virustotal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ function rescan($hash,$maxage=7) {
curl_close ($ch);

$reply = json_decode($api_reply);
try {
if ( property_exists($reply,'response_code') ) {
$api_rc = $reply->response_code;
} catch (Exception $e) {
} else {
$api_rc = -99;
}
if ( $api_rc === '' ) $api_reply = -99;
Expand Down Expand Up @@ -152,7 +152,7 @@ public function checkFile($fileName='', $hash='') {

// first check if a report for this file already exists, so we don't need to upload
$report_url = 'https://www.virustotal.com/vtapi/v2/file/report?apikey='.$this->api_key."&resource=".$hash;
$api_reply = file_get_contents($report_url);
if ( ! $api_reply = @file_get_contents($report_url) ) $api_reply = '';
( $api_reply === '' ) ? $api_reply_array = ['response_code'=>-99,'verbose_msg'=>'Got empty response from VirusTotal'] : $api_reply_array = json_decode($api_reply, true);

// continue depending on the result
Expand Down

0 comments on commit b75ab36

Please sign in to comment.