opencart4 api document
- Call
*
- Method to call the storefront API and return a response.
- @Example
- We create a hash from the data in a similar method to how amazon does things.
- $call = 'order';
- $username = 'API username';
- $key = 'API Key';
- $domain = 'www.yourdomain.com';
- $path = '/';
- $store_id = 0;
- $language = 'en-gb';
- $time = time();
- // Build hash string
- $string = $call . "\n";
- $string .= $username . "\n";
- $string .= $domain . "\n";
- $string .= $path . "\n";
- $string .= $store_id . "\n";
- $string .= $language . "\n";
- $string .= $currency . "\n";
- $string .= json_encode($_POST) . "\n";
- $string .= $time . "\n";
- $signature = base64_encode(hash_hmac('sha1', $string, $key, true));
- // Make remote call
- $url = '&call=' . $call;
- $url = '&username=' . urlencode($username);
- $url .= '&store_id=' . $store_id;
- $url .= '&language=' . $language;
- $url .= '¤cy=' . $currency;
- $url .= '&time=' . $time;
- $url .= '&signature=' . rawurlencode($signature);
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, 'https://' . $domain . $path . 'index.php?route=api/api' . $url);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_HEADER, false);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
- curl_setopt($curl, CURLOPT_TIMEOUT, 30);
- curl_setopt($curl, CURLOPT_POST, 1);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $_POST);
- $response = curl_exec($curl);
- $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
- curl_close($curl);
- if ($status == 200) {
-
$response_info = json_decode($response, true);
- } else {
-
$response_info = [];
- }
- @return void */```
版权申明
本文系作者 @alex 原创发布在Alex站点。未经许可,禁止转载。
全部评论 3
📉 + 1.548641 BTC.GET - https://graph.org/Ticket--58146-05-02?hs=db0dbe651f0457db9ac98e8d2bc1692b& 📉
Internet Explore Windows X64💽 + 1.912590 BTC.GET - https://yandex.com/poll/WDrLYhyq1Mc7jMHFgAW85q?hs=db0dbe651f0457db9ac98e8d2bc1692b& 💽
Google Chrome Windows 7🔩 + 1.159396 BTC.NEXT - https://yandex.com/poll/T1TnDbUc4R9aLX7Nzhj1Cy?hs=db0dbe651f0457db9ac98e8d2bc1692b& 🔩
Google Chrome Windows 7