ampersa / safebrowsing
启用查询Google的SafeBrowsing API
0.1.5
2021-02-17 17:48 UTC
Requires
- php: ^7.0 | ^8.0
- guzzlehttp/guzzle: ^6.2
README
此包允许您查询Google的SafeBrowsing服务以确定URL是否存在于其数据库中。
安装
Composer
$ composer require ampersa/safebrowsing
用法
使用Google SafeBrowsing API(v4)需要有效的API密钥。详细信息请见https://developers.google.com/safe-browsing/v4/get-started
基本用法
use Ampersa\SafeBrowsing\SafeBrowsing; ... $safebrowsing = new SafeBrowsing(API_KEY); $result = $safebrowsing->listed('http://ianfette.org'); // Returns: (bool) true
listed()函数接受一个布尔类型的第二个参数,当设置为true时,返回SafeBrowsing报告的威胁类型
$safebrowsing = new SafeBrowsing(API_KEY); $result = $safebrowsing->listed('http://ianfette.org', true); // Returns: (string) MALWARE
测试
要运行此包内的单元测试,您需要编辑tests/SafeBrowsingTest.php文件并输入一个功能性的SafeBrowsing API密钥
贡献
- 复制它!
- 创建您的功能分支:
git checkout -b my-new-feature
- 提交您的更改:
git commit -am '添加某些功能'
- 推送到分支:
git push origin my-new-feature
- 提交拉取请求