neilcrookes / oauth2-ebay
为PHP League OAuth2-Client提供的eBay OAuth 2.0客户端提供程序
dev-master
2019-10-29 10:17 UTC
Requires
- php: >=5.6.0
- league/oauth2-client: ^2.0
This package is auto-updated.
Last update: 2024-09-18 21:01:30 UTC
README
本包为PHP League的OAuth 2.0客户端提供Ebay OAuth 2.0支持。
安装
要安装,请使用composer
composer require neilcrookes/oauth2-ebay
用法
用法与The League的OAuth客户端相同,使用NeilCrookes\OAuth2\Client\Provider\Ebay
作为提供者。
$provider = new \NeilCrookes\OAuth2\Client\Provider\Ebay([
'clientId' => 'YOUR EBAY APP ID',
'clientSecret' => 'YOUR EBAY CERTIFICATE ID',
'redirectUri' => 'YOUR EBAY "RU" NAME',
'sandbox' => true, //defaults to false, i.e. production
'http_errors' => false, // Optional. Means Guzzle Exceptions aren't thrown on 4xx or 5xx responses from eBay, allowing you to detect and handle them yourself
], [
'optionProvider' => new \League\OAuth2\Client\OptionProvider\HttpBasicAuthOptionProvider()
]);
$accessToken = $provider->getAccessToken('authorization_code', [
'code' => $_GET['code']
]);
$ebayUser = $provider->getResourceOwner($accessToken);
echo $ebayUser->getId(); // eBay User's user id
echo $ebayUser->getEmail(); // eBay User's email address