visualappeal / php-ssllabs-api
ssllabs.com API
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: ^7.4
This package is auto-updated.
Last update: 2024-09-11 14:06:38 UTC
README
这个PHP库提供了对SSL Labs API的基本访问。
安装
composer require visualappeal/php-ssllabs-api
使用方法
它基于官方API文档 https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md
<?php require_once 'vendor/autoload.php'; //Return API response as JSON string $api = new SslLabs(); //Return API response as JSON object //$api = new SslLabs(true); //get API information var_dump($api->fetchApiInfo()); ?>
方法
info()
无需参数
返回一个Info对象(见 https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#info)。
getStatusCodes()
无需参数
返回一个StatusCodes实例(见 https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#statuscodes)。
analyze()
请参阅 https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#invoke-assessment-and-check-progress 了解参数描述。
返回一个Host对象(见 https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#host)。
请确保检查Host对象内的'status'属性。
analyzeCached()
您也可以使用带有正确参数的fetchHostInformation(),这只是一个辅助函数。
返回一个Host对象(见 https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#host)。
请确保检查Host对象内的'status'属性。
getEndpointData()
返回一个Endpoint对象(见 https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#endpoint)。
自定义API调用
使用sendApiRequest()方法创建自定义API调用。
$api->sendApiRequest('apiCallName', array('p1' => 'p1_value', 'p2' => 'p2_value'));
getReturnObjects()
returnObjects的获取器
setReturnObjects()
returnObjects的设置器
示例输出(作为JSON字符串)
获取API信息
$api->info();
{ "engineVersion": "1.15.1", "criteriaVersion": "2009i", "clientMaxAssessments": 25, "maxAssessments": 25, "currentAssessments": 0, "messages": [ "This assessment service is provided free of charge by Qualys SSL Labs, subject to our terms and conditions: https://www.ssllabs.com/about/terms.html" ] }
获取主机信息
$api->analyze('https://www.google.de');
{ "host": "https://www.google.de", "port": 443, "protocol": "HTTP", "isPublic": false, "status": "READY", "startTime": 1427195976527, "testTime": 1427196284525, "engineVersion": "1.15.1", "criteriaVersion": "2009i", "endpoints": [ { "ipAddress": "74.125.239.119", "serverName": "nuq05s01-in-f23.1e100.net", "statusMessage": "Ready", "grade": "B", "hasWarnings": false, "isExceptional": false, "progress": 100, "duration": 77376, "eta": 1610, "delegation": 3 }, { "ipAddress": "74.125.239.120", "serverName": "nuq05s01-in-f24.1e100.net", "statusMessage": "Ready", "grade": "B", "hasWarnings": false, "isExceptional": false, "progress": 100, "duration": 76386, "eta": 1609, "delegation": 3 }, { "ipAddress": "74.125.239.127", "serverName": "nuq05s01-in-f31.1e100.net", "statusMessage": "Ready", "grade": "B", "hasWarnings": false, "isExceptional": false, "progress": 100, "duration": 76937, "eta": 1608, "delegation": 3 }, { "ipAddress": "74.125.239.111", "serverName": "nuq05s01-in-f15.1e100.net", "statusMessage": "Ready", "grade": "B", "hasWarnings": false, "isExceptional": false, "progress": 100, "duration": 77171, "eta": 1606, "delegation": 3 } ] }
获取端点信息
$api->getEndpointData('https://www.google.de', '74.125.239.111');
(仅为整个JSON输出的部分)
{ "ipAddress": "74.125.239.111", "serverName": "nuq05s01-in-f15.1e100.net", "statusMessage": "Ready", "grade": "B", "hasWarnings": false, "isExceptional": false, "progress": 100, "duration": 77171, "eta": 1609, "delegation": 3, "details": { "hostStartTime": 1427195976527, "key": {}, "cert": {}, "chain": {}, "protocols": [], "suites": {}, "serverSignature": "gws", "prefixDelegation": true, "nonPrefixDelegation": true, "vulnBeast": false, "renegSupport": 2, "sessionResumption": 1, "compressionMethods": 0, "supportsNpn": true, "npnProtocols": "h2-15 h2-14 spdy/3.1 spdy/3 http/1.1", "sessionTickets": 1, "ocspStapling": false, "sniRequired": false, "httpStatusCode": 200, "supportsRc4": true, "forwardSecrecy": 2, "rc4WithModern": true, "sims": {}, "heartbleed": false, "heartbeat": false, "openSslCcs": 1, "poodleTls": 1, "fallbackScsv": true } }
条款和条件
由于这是一个用于SSL Labs API的PHP库,请参阅SSL Labs的条款和条件 https://www.ssllabs.com/about/terms.html