PHP code example of cblink-service / shop
1. Go to this page and download the library: Download cblink-service/shop 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/ */
cblink-service / shop example snippets
$config = [
'private' => true,
'debug' => true,
'base_url' => 'https://127.0.0.1',
'app_id' => 1234,
'key' => 'xxxxx',
'secret' => 'xxxxxxxxx',
];
$app = new Cblink\Service\Shop\Application($config);
// 创建饿了么应用
$app->app->create([
'name' => '应用名称',
'type' => \Cblink\Service\Shop\ShopConst::TYPE_ELEME,
'config' => [
'app_id' => 'xxxx',
'secret' => 'xxxx',
'debug' => true,
]
]);
// 创建美团应用
$app->app->create([
'name' => '应用名称',
'type' => \Cblink\Service\Shop\ShopConst::TYPE_MEITUAN,
'config' => [
'developer_id' => 'xxxx',
'sign' => 'xxxx',
]
]);
// 查询应用下的通知地址
$app->app->notifies('应用id');
// 保存或修改通知地址
$app->app->createNotify('应用id', \Cblink\Service\Shop\ShopConst::EVENT_ORDER_CREATE, 'https://www.baodu.com');
// state参数最终会在授权跳转页面去返回
$app->eleme->getAuthUrl('xxxx', '授权成功的跳转地址', 'state');
// 美团
$app->meituan->getAuthUrl('xxxx', '授权成功的跳转地址', 'state');