Skip to content

laraver/eleme-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eleme-sdk

饿了么 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(...)