iCo*_*ers 2 php codeigniter safe-browsing laravel
我正在尝试使用 Google 安全浏览 API 检查 url 是否安全
我遵循以下教程
https://developers.google.com/safe-browsing/v4/get-started
我已按照上述网址指南完成了以下步骤
最后我得到了 https://safebrowsing.googleapis.com/v4/...?key=API_KEY
我的问题是如何将网站网址传递到安全浏览网址之上
完成以下步骤以启用 API 并获取 API 密钥:
这是 cURL 代码 100% 工作
curl -X POST \
'https://safebrowsing.googleapis.com/v4/threatMatches:find?key=YOUR_KEY_HERE' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: ec7ffd77-d3fa-f017-44f9-d895efaba258' \
-d ' {
"client": {
"clientId": "yourcompanyname",
"clientVersion": "1.5.2"
},
"threatInfo": {
"threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"],
"platformTypes": ["WINDOWS"],
"threatEntryTypes": ["URL"],
"threatEntries": [
{"url": "https://accounts-wallets.redirectme.net/webapps/57a39/websrc"},
{"url": "http://stackoverflow.com/"}
]
}
}'
Run Code Online (Sandbox Code Playgroud)
我得到了输出
{
"matches": [
{
"threatType": "SOCIAL_ENGINEERING",
"platformType": "WINDOWS",
"threat": {
"url": "https://accounts-wallets.redirectme.net/webapps/57a39/websrc"
},
"cacheDuration": "300s",
"threatEntryType": "URL"
}
]
}
Run Code Online (Sandbox Code Playgroud)
Python 示例
import requests
url = "https://safebrowsing.googleapis.com/v4/threatMatches:find"
querystring = {"key":"YOUR_KEY"}
payload = """
{
"client": {
"clientId": "yourcompanyname",
"clientVersion": "1.5.2"
},
"threatInfo": {
"threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"],
"platformTypes": ["WINDOWS"],
"threatEntryTypes": ["URL"],
"threatEntries": [
{"url": "https://accounts-wallets.redirectme.net/webapps/57a39/websrc"},
{"url": "http://stackoverflow.com/"}
]
}
}
"""
headers = {
'content-type': "application/json",
'cache-control': "no-cache",
'postman-token': "460d6d44-4a55-d6ab-fb58-2ff9fb306154"
}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)
Run Code Online (Sandbox Code Playgroud)
PHP 示例
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://safebrowsing.googleapis.com/v4/threatMatches:find?key=YOUR_KEY",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => ' {
"client": {
"clientId": "yourcompanyname",
"clientVersion": "1.5.2"
},
"threatInfo": {
"threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"],
"platformTypes": ["WINDOWS"],
"threatEntryTypes": ["URL"],
"threatEntries": [
{"url": "https://accounts-wallets.redirectme.net/webapps/57a39/websrc"},
{"url": "http://stackoverflow.com/"}
]
}
}',
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json",
"postman-token: b05b8d34-85f2-49cf-0f8e-03686a71e4e9"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3911 次 |
| 最近记录: |