laraver/eleme-sdk

There is no license information available for the latest version (1.0.0) of this package.

饿了么 SDK

1.0.0 2019-09-18 06:55 UTC

This package is not auto-updated.

Last update: 2024-12-22 05:57:13 UTC


README

饿了么 SDK

安装

composer require laraver/eleme-sdk:dev-master

文档

实例化

$eleme = new Eleme([
    'app_id' => '',
    'secret' => '',
    'debug'  => true,
    'log' => [
        'file' => storage_path('logs/eleme.log'),
        'level'      => 'debug',
        'permission' => 0777,
    ]
]);

获取授权链接

$url = $eleme->oauth->pre_auth->request($callbackUrl)->getTargetUrl();

获取授权门店

$accessToken = $eleme->oauth->getToken();

$eleme = $eleme->oauth->createAuthorizerApplication($accessToken['access_token']);

// 获取门店信息
$response = $eleme->user->getUser();

获取门店的实例

$eleme = $eleme->oauth->createAuthorizerApplication($access_token);

其他实例

// 订单实例
$order = $eleme->order;

PS: 其他请参考 https://github.com/hanson/eleme-sdk/blob/master/src/Eleme.php 中的备注

接收推送

$response = $eleme->server->serve();

if (!$response) {
    return;
}

$message = json_decode($response['message'], true);

if ($response['type'] == 10) { // 订单生效

} 
# elseif(...)