macropage/oauth2-ebay

The PHP League OAuth2-Client 的 eBay OAuth 2.0 客户端提供者

dev-master 2020-06-08 17:47 UTC

This package is auto-updated.

Last update: 2024-09-09 03:11:49 UTC


README

分支自: https://github.com/neilcrookes/oauth2-ebay

OAuth 2.0 客户端的 eBay 提供者

此包为 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