
VirusTotal API: 这是一个提供免费的网址检测 API。您需要首先注册一个账号,获取 API 密钥,然后集成到您的 PHP 代码中。它可以检测网址是否存在任何恶意软件或病毒。
示例代码:
$url = 'https://www.example.com';
$apikey = 'your_api_key';
$response = file_get_contents("https://www.virustotal.com/vtapi/v2/url/report?apikey=$apikey&resource=$url");
$json_response = json_decode($response, true);
if($json_response['response_code'] == 1 && $json_response['positives'] > 0){
echo "The website is not safe";
}else{
echo "The website is safe";
}
Google Safe Browsing API: 这是由 Google 提供的另一个免费的安全检测 API。您可以使用它来检测网址是否受到谷歌认为的威胁。
示例代码:
$url = 'https://www.example.com';
$apikey = 'your_api_key';
$response = file_get_contents("https://safebrowsing.googleapis.com/v4/threatMatches:find?key=$apikey");
$params = array(
'client' => array(
'clientId' => 'your_company_name',
'clientVersion' => '1.0.0'
),
'threatInfo' => array(
'threatTypes' => array('MALWARE','SOCIAL_ENGINEERING','UNWANTED_SOFTWARE','POTENTIALLY_HARMFUL_APPLICATION'),
'platformTypes' => array('WINDOWS','LINUX','ANDROID'),
'threatEntryTypes' => array('URL'),
'threatEntries' => array(
array('url' => $url)
)
)
);
$options = array(
'http' => array(
'header' => "Content-Type: application/json",
'method' => 'POST',
'content' => json_encode($params)
)
);
$context = stream_context_create($options);
$result = file_get_contents("https://safebrowsing.googleapis.com/v4/threatMatches:find?key=$apikey", false, $context);
$json_result = json_decode($result, true);
if(!empty($json_result['matches'])){
echo "The website is not safe";
}else{
echo "The website is safe";
}
请注意,使用这些 API 需要注册并获取 API 密钥。此外,请注意 API 限制和条款,以确保您不会滥用或违反任何规则。
- All rights reserved.
- No part of this website, including text and images, may be reproduced, modified, distributed, or transmitted in any form or by any means, without the prior written permission of the author.
- Unauthorized commercial use is strictly prohibited.
- Unauthorized personal use is strictly prohibited.