larowka / kudago-api
KudaGo API 的 PHP 封装
v0.4.1
2021-11-26 21:20 UTC
Requires
- php: ^7.3|^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^5.5 || ^6.0 || ^7.0 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.5.10
README
基于 Guzzle Http Client 的 KudaGo API 的 PHP 封装
要求
- PHP 7.3 或更高版本
安装
通过 Composer
$ composer require larowka/kudago-api
或者你可以更新你的 composer.json 文件
{ "require": { "larowka/kudago-api": "0.2.*" } }
Laravel
Lumen
使用示例
创建 API 封装实例
use Larowka\KudaGo\Api; $kudago = new Api();
特质
一些实体有用于排序、详情、按时间或坐标筛选和分页的通用特质。使用 IDE 注释或 官方文档 获取允许的参数。
$events = $kudago->events(); // Sorting $events->orderBy('id', '-publication_date') // Order by id ASC and by publication_date DESC ->get(); // Details $events->expand('images', 'dates') // Get detailed information of images and dates in result ->get(); // Filter by time $events->before('2022', '!Y') // Get results between 2021-10-12 and 2022 year ->after('2021-10-12', 'Y-m-d') ->get(); // Filter by coordinates $events->inRadius(59.9, 30.3, 10000) // Include only events in radius 10000 meters around point [latitude, longitude] ->get(); // Paginator $events->page(3) // Page number ->pageSize(35) // Items on page ->get(); // Concrete object $events->find(161043); // find by event ID
API 端点
对象类别 (文档)
$categories = $kudago->categories(); $eventCategories = $categories->events()->get(); $placeCategories = $categories->places()->get();
位置 (文档)
特质: 排序
$locations = $kudago->locations(); $cities = $locations->orderBy('timezone')->get(); $city = $locations->find('spb');
搜索 (文档)
特质: 分页器、详情、坐标筛选器
$kudago->search() ->query('art') // Query string ->type('event') // Include only specific type: news, event, place, list ->expand('place', 'dates') ->get();
事件 (文档)
特质: 分页器、排序、详情、时间筛选器、坐标筛选器
$kudago->events() ->after('2021-10-11') ->orderBy('-publication_date') ->page(5) ->pageSize(50) ->get();
每日事件 (文档)
$kudago->eventsOfTheDay()->get();
新闻 (文档)
$kudago->news()->get();
列表 (文档)
特质: 分页器、排序、详情
$kudago->lists()->get();
地点 (文档)
特质: 分页器、排序、详情、时间筛选器、坐标筛选器
$kudago->places() ->ids(157,33338) // Include only specific places by placeID ->get();
电影 (文档)
特质: 分页器、排序、详情、时间筛选器
$kudago->movies()->get();
放映 (文档)
特质: 分页器、排序、详情、时间筛选器
$kudago->showings() ->inPlace(19757) // Include only showings in specific place ->get();
电影放映 (文档)
特质: 分页器、排序、详情、时间筛选器
$kudago->movieShowings(3315) ->inPlace(19757) // Include only showings in specific place ->get();
代理商 (文档)
$kudago->agents()->get();
代理商角色 (文档)
$kudago->agentRoles()->get();