legnd/singleplatform-php

Legnd SinglePlatform PHP(或 Laravel 5.6+)包。

v1.0.4 2018-06-15 16:18 UTC

This package is not auto-updated.

Last update: 2024-09-21 08:57:01 UTC


README

通过composer要求

composer require legnd/singleplatform-php

用法

简单的PHP示例

require 'vendor/autoload.php';
use \Legnd\SinglePlatform\Api\PublisherApi;
use \Legnd\SinglePlatform\SinglePlatform;

$id     = 'my-restaurant';
$config = [
    'token'  => 'YOUR_CLIENT_KEY', // Note: this is the Client Key not the API token
    'secret' => 'YOUR_CLIENT_SECRET'
];

$api = new PublisherApi(new GuzzleHttp\Client([
   'base_url' => PublisherApi::$baseUrl
]), $config);

$service = new SinglePlatform($id, $api);

echo $service->getMenus()[0]->sections()[0]->items()[0]->price;

Laravel(通过Service Provider)

包发现

服务提供者将通过Composer自动由Laravel发现

发布配置(可选)

php artisan vendor:publish

添加以下.env变量

SINGLEPLATFORM_KEY=YOUR_CLIENT_KEY
SINGLEPLATFORM_SECRET=YOUR_CLIENT_SECRET
SINGLEPLATFORM_LOCATION=YOUR_RESTAURANT_ALPHAID

在控制器中使用

use Facades\Legnd\SinglePlatform\SinglePlatform;

class RestaurantController {

    public function menus()
    {
        return SinglePlatform::getMenus();
    }

}