wiatorgon/allegro-rest-api
Allegro REST API 的简单接口
0.0.7
2018-05-15 19:31 UTC
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-09-19 10:30:30 UTC
README
Allegro REST API 资源的简单接口
授权和令牌
为了使用 Allegro REST Api,您必须注册您的应用程序并授权它(https://developer.allegroapi.io/auth/)。
授权链接
$api = new Api($clientId, $clientSecret, $apiKey, $redirectUri, null, null); echo $api->getAuthorizationUri();
获取新令牌
# example contents of your_redirect_uri.com/index.php $code = $_GET['code']; $api = new Api($clientId, $clientSecret, $apiKey, $redirectUri, null, null); $response = $api->getNewAccessToken($code); # response contains json with your access_token and refresh_token
刷新现有令牌
$api = new Api($clientId, $clientSecret, $apiKey, $redirectUri, $accessToken, $refreshToken); $response = $api->refreshAccessToken(); # response contains json with your new access_token and refresh_token
示例用法
$api = new Api($clientId, $clientSecret, $apiKey, $redirectUri, $accessToken, $refreshToken); // GET https://allegroapi.io/{resource} // $api->{resource}->get(); // GET https://allegroapi.io/categories $api->categories->get(); // GET https://allegroapi.io/{resource}/{resource_id} // $api->{resource}({resource_id})->get(); // GET https://allegroapi.io/categories/2 $api->categories(2)->get(); // PUT https://allegroapi.io/{resource}/{resource_id}/{command-name}-command/{uuid} // $api->{resource}({resource_id})->commands()->{command_name}($data); // PUT https://allegroapi.io/offers/12345/change-price-commands/84c16171-233a-42de-8115-1f1235c8bc0f $api->offers(12345)->commands()->change_price($data);