1. Go to this page and download the library: Download sobyte/eleme-openapi-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sobyte / eleme-openapi-sdk example snippets
composer
use ElemeOpenApi\Config\Config;
use ElemeOpenApi\Api\ShopService;
//实例化一个配置类
$config = new Config($app_key, $app_secret, false);
//使用config和token对象,实例化一个服务对象
$shop_service = new ShopService($token, $config);
//调用服务方法,获取资源
$shop = shop_service->get_shop(12345);
use ElemeOpenApi\Config\Config;
use ElemeOpenApi\OAuth\OAuthClient;
//实例化一个配置类
$config = new Config($app_key, $app_secret, false);
//使用config对象,实例化一个授权类
$client = new OAuthClient($config);
//根据OAuth2.0中的对应state,scope和callback_url,获取授权URL
$auth_url = $client->get_auth_url($state, $scope, $callback_url);
use ElemeOpenApi\Config\Config;
use ElemeOpenApi\OAuth\OAuthClient;
//实例化一个配置类
$config = new Config($app_key, $app_secret, false);
//使用config对象,实例化一个授权类
$client = new OAuthClient($config);
//使用授权类获取token
$token = $client->get_token_in_client_credentials();