gacelabs / toktok-api
Toktok API
dev-main
2023-09-25 00:23 UTC
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2024-09-25 02:36:38 UTC
README
toktok-api
如何通过后端/端点调用管理toktok配送
要求
- PHP 7.0及更高版本
安装
使用composer
composer require gacelabs/toktok-api dev-main
使用zip包下载 https://github.com/gacelabs/toktok-api/archive/refs/heads/main.zip
声明
define('TOKTOK_USER', '<YOUR PORTAL USERNAME>'); define('TOKTOK_PASSWORD', '<YOUR PORTAL PASSWORD>'); define('REFERRAL_CODE', '<YOUR TOKTOK REFERRAL CODE>');
用法
include ('path/to/ToktokApi.php'); $api = new ToktokApi;
存在两种类型的端点列表
- 门户
- 网站
这将在endpoint_list($type)私有方法中指定,其中$type是(门户或网站)。
在第184行找到
示例
要获取toktok定价和配送方向,您可以使用此方法作为您的助手 toktok_price_directions_format.php。
(请参阅$toktok_post 格式)。
$pricing = price_and_directions($api, $toktok_post); $api->app_request('price_and_directions', $pricing); if ($api->success) { $toktok_dpd = $api->response['result']['data']['getDeliveryPriceAndDirections']; $toktok_post['f_post'] = json_encode(['hash'=>$toktok_dpd['hash']], JSON_NUMERIC_CHECK); $toktok_post['f_distance'] = $toktok_dpd['pricing']['distance'] . ' km'; $toktok_post['f_duration'] = format_duration($toktok_dpd['pricing']['duration']); $toktok_post['f_price'] = $toktok_dpd['pricing']['price']; $toktok_post['f_sender_mobile'] = preg_replace('/-/', '', $toktok_post['f_sender_mobile']); $toktok_post['f_recepient_mobile'] = preg_replace('/-/', '', $toktok_post['f_recepient_mobile']); $toktok_post['referral_code'] = REFERRAL_CODE; }
通过toktok api发布订单
$api->app_request('post_delivery', $toktok_post); if ($api->success) { // get results here $data = $api->response; } else { // throw $api->response error here }
如果你喜欢我的工作?任何数额的捐款都将非常感谢 🙌🙏🤝
谢谢!
报告问题
请创建问题报告任何错误,或提交合并请求。
