gacelabs/toktok-api

Toktok API

安装: 6

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 1

分支: 0

开放问题: 0

类型:插件

dev-main 2023-09-25 00:23 UTC

This package is auto-updated.

Last update: 2024-09-25 02:36:38 UTC


README

Image of Toktok

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
}

如果你喜欢我的工作?任何数额的捐款都将非常感谢 🙌🙏🤝

PAY PAL.ME

谢谢!

报告问题

创建问题报告任何错误,或提交合并请求。