amattu2 / nhtsa-wrapper
一个基于PHP的简单NHTSA(美国交通部)车辆VIN解码和召回查询API包装器。
v1.0.1
2023-03-19 15:16 UTC
This package is auto-updated.
Last update: 2024-09-19 18:49:40 UTC
README
这是一个NHTSA(美国交通部)VIN解码API的简单包装器。此外,它还包括NHTSA车辆召回API。请参阅下面的使用部分或示例index.php
文件。
使用方法
导入
使用Composer安装
require amattu2/nhtsa-wrapper
require "vendor/autoload.php";
VIN解码
原始解码
PHPDoc
/** * Decode a 17-digit VIN * * @param string vin number * @param ?integer model year * @return ?array raw NHTSA result * @throws TypeError * @author Alec M. <https://amattu.com> * @date 2021-04-04T16:19:40-040 */
使用方法
$decode = amattu2\NHTSA\Client::decodeVIN("VIN_NUMBER");
成功返回结果
Array
(
[Error Text] =>
[Make] =>
[Manufacturer Name] =>
[Model] =>
[Model Year] =>
[Plant City] =>
[Series] =>
[Trim] =>
[Vehicle Type] =>
[Plant Country] =>
...
)
美化解码
PHPDoc
/** * Parse a raw decode call * Converts a decodeVIN call into a pretty parsed Year, Make, Model, Trim, Engine array * * @param array raw decode result * @return ?array pretty parsed NHTSA result * @throws TypeError * @author Alec M. <https://amattu.com> * @date 2021-04-04T16:52:15-040 */
使用方法
$decode = amattu2\NHTSA\Client::decodeVIN("VIN_NUMBER"); $pretty_decode = amattu2\NHTSA\Client::parseDecode($decode);
成功返回结果(示例)
Array ( [Model_Year] => 2011 [Make] => MERCEDES-BENZ [Model] => M-CLASS [Trim] => 4-MATIC [Engine] => 3.5L 6-CYL (3,500CC) )
召回
原始召回
PHPDoc
/** * Get vehicle recalls by Year, Make, Model * * @param int model year * @param string make * @param string model * @return ?array NHTSA raw result * @throws TypeError * @author Alec M. <https://amattu.com> * @date 2021-04-04T16:48:24-040 */
使用方法
$recalls = amattu2\NHTSA\Client::getRecalls(2015, "Ford", "Mustang");
成功返回结果
Array
(
[0] => Array
(
[Manufacturer] =>
[NHTSACampaignNumber] =>
[ReportReceivedDate] =>
[Component] =>
[Summary] =>
[Conequence] =>
[Remedy] =>
[Notes] =>
[ModelYear] =>
[Make] =>
[Model] =>
)
...
)
美化召回
PHPDoc
/** * Parse a raw recall result * * @param array raw recall result * @return ?array parsed recall result * @throws TypeError * @author Alec M. <https://amattu.com> * @date 2021-04-04T18:16:26-040 */
使用方法
$recalls = amattu2\NHTSA\Client::getRecalls(2015, "Ford", "Mustang"); $pretty_recalls = amattu2\NHTSA\Client::parseRecalls($recalls);
成功返回结果
Array
(
[2] => Array
(
[Campaign_Number] =>
[Component] => Array
(
[0] => FUEL SYSTEM, GASOLINE
[1] => STORAGE
[2] => TANK ASSEMBLY /* The last element is the actual component */
)
[Date] => 2015-06-02
[Description] =>
[Remedy] =>
)
...
)
需求 & 依赖
PHP 7.0 +