amattu2 / vinwiki-wrapper
一个VINwiki.com API包装器。开放访问VINWiki API功能;通过VIN获取数据,使用plate2vin(pl82vin),向数据源添加新事件等。
Requires
- php: >=7.4
- ext-curl: *
This package is auto-updated.
Last update: 2024-09-21 19:10:41 UTC
README
这是一个非官方的且无依赖性的 VINwiki.com API包装器,用PHP编写。它提供了一个简单的接口来与VINwiki API交互。其中包括以下功能:
- 读取和更新用户资料
- 读取和更新车辆信息
- 读取、创建和删除帖子
- 按国家/州解码车牌
- 通过VIN、年份、制造商、型号或自由文本搜索车辆
用法
安装
通过Composer
composer require amattu2/vinwiki-wrapper
然后,需要Composer的自动加载器
require 'vendor/autoload.php';
实例化类
$wrapper = new amattu2\VINwiki\Client("email|username", "password");
函数
人物
这些函数与人物交互相关。
getPersonProfile(string $uuid = "") : ?VINwiki\Models\Person
返回一个VINwiki用户资料。如果没有指定用户,则返回当前用户的资料。
// for the current user print_r($wrapper->getPersonProfile()); // or for a specific user print_r($wrapper->getPersonProfile("61382da4-25c6-494f-8065-87afdfb4f50d"));
updatePersonProfile(string $uuid, VINwiki\Models\Person $person): ?VINwiki\Models\Person
更新当前用户的资料。在成功的情况下返回更新后的资料。唯一必需的字段是"email"。
有关更多字段,请参阅 Models\Person。
$person = new amattu2\VINwiki\Models\Person([ "email" => "abc123@example.com", ]); print_r($wrapper->updatePersonProfile("{UUID GOES HERE}", $person));
getPersonNotifications() : ?array
获取当前用户的通知。
print_r($wrapper->getPersonNotifications());
getPersonFeed(string $uuid = "", bool $filterFollowing = true): ?Models\PersonFeed
获取一个用户的帖子数据源。如果没有指定 $uuid
,则返回当前用户的帖子数据源。如果 $filterFollowing
为true,则仅返回指定用户关注的车辆/人物的帖子。
// for the current user print_r($wrapper->getPersonFeed()); // or for a specific user print_r($wrapper->getPersonFeed("61382da4-25c6-494f-8065-87afdfb4f50d", false));
getPersonPosts(string $uuid = ""): ?VINwiki\Models\PersonPosts
获取一个用户的帖子。如果没有指定用户,则返回当前用户的帖子。
// for the current user print_r($wrapper->getPersonPosts()); // or for a specific user print_r($wrapper->getPersonPosts("61382da4-25c6-494f-8065-87afdfb4f50d"));
getRecentVins(): ?VINwiki\Models\RecentVins
返回用户最近发布或交互的车辆列表。不包括用户仅查看的车辆。
print_r($wrapper->getRecentVins());
车辆
这些函数处理任何与车辆相关的交互。
plateLookup(string $plate, string $country, string $state): ?VINwiki\Models\PlateLookup
通过车牌解码车辆。目前支持美国/英国车牌。
print_r($wrapper->plateLookup("HELLO", "US", "CA"));
getFeed(string $vin): ?VINwiki\Models\VehicleFeed
获取一辆车辆的帖子数据源(即访问VINwiki.com上车辆的页面时)
print_r($wrapper->getFeed("WBAPL33579A406957"));
getVehicle(string $vin): ?VINwiki\Models\Vehicle
通过VIN获取车辆信息。
print_r($wrapper->getVehicle("WBAPL33579A406957"));
vehicleSearch(string $query): ?VINwiki\Models\VehicleSearch
通过年份、制造商、型号或VIN进行自由文本搜索车辆。
print_r($wrapper->vehicleSearch("2011 Toyota Corolla"));
updateVehicle(string $vin, int $year, string $make, string $model, string $trim = ""): bool
通过VIN更新车辆的年份、制造商、型号和型号。如果成功则返回true。
print_r($wrapper->updateVehicle("WBAPL33579A406957", 2009, "BMW", "335i", "xDrive"));
createPost(string $vin, VINwiki\Models\VehiclePost $post): ?VINwiki\Models\FeedPost
在车辆上创建新的帖子。需要一个VIN和一个VehiclePost对象。在成功的情况下返回新的帖子。
有关更多信息,请参阅 Models\VehiclePost。
// Create a new post class $post = new amattu2\VINwiki\Models\VehiclePost([ "mileage" => 43000, "text" => "This is a test post from the VINwiki-Wrapper PHP library.", ]); // Post it print_r($wrapper->createPost("WBAPL33579A406957", $post));
deletePost(string $uuid) : bool
通过UUID删除帖子。如果成功则返回true。需要用户是帖子的作者。
print_r($wrapper->deletePost("61382da4-25c6-494f-8065-87afdfb4f50d"));
要求
- PHP 7.4+
- cURL
- Composer(推荐)