gacelabs / toktok-api
Toktok API
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:plugin
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2024-04-25 01:41:08 UTC
README
toktok-api
How to manage toktok deliveries thru Backend / end point calls
Requirements
- PHP 7.0 and up
Installation
with composer
composer require gacelabs/toktok-api dev-main
with zip https://github.com/gacelabs/toktok-api/archive/refs/heads/main.zip
Declarations
define('TOKTOK_USER', '<YOUR PORTAL USERNAME>'); define('TOKTOK_PASSWORD', '<YOUR PORTAL PASSWORD>'); define('REFERRAL_CODE', '<YOUR TOKTOK REFERRAL CODE>');
Usage
include ('path/to/ToktokApi.php'); $api = new ToktokApi;
There are two types of end point list:
- portal
- website
This is assigned in the endpoint_list($type)
private method, where $type
is (portal or website).
Found in Line 184
Example
To get toktok pricing and delivery directions, You can use this methos as your helper toktok_price_directions_format.php.
(Please see $toktok_post format).
$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; }
Posting your order via toktok api:
$api->app_request('post_delivery', $toktok_post); if ($api->success) { // get results here $data = $api->response; } else { // throw $api->response error here }
IF YOU LIKE MY WORK HERE? ANY AMOUNT OF DONATIONS WILL BE GLADLY APPRECIATED 🙌🙏🤝
THANK YOU!
Reporting Issues
Please create an issue for any bugs, or submit merge requests.