#
知识
2025-05-03
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 */```
TAGS:
无标签
YOU MAY ALSO LIKE
- 暂无相关推荐,看看别的吧。
r1lvr4
wne5yt
slc2m4