All posts

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. $ca

  • 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 = '/'; * $storeid = 0; * $language = 'en-gb'; * $time = time(); * * // Build hash string * $string = $call . "\n"; * $string .= $username . "\n"; * $string .= $domain . "\n"; * $string .= $path . "\n"; * $string .= $storeid . "\n"; * $string .= $language . "\n"; * $string .= $currency . "\n"; * $string .= jsonencode($POST) . "\n"; * $string .= $time . "\n"; * * $signature = base64encode(hashhmac('sha1', $string, $key, true)); * * // Make remote call * $url = '&call;=' . $call; * $url = '&username;=' . urlencode($username); * $url .= '&store;id=' . $storeid; * $url .= '&language;=' . $language; * $url .= '&currency;=' . $currency; * $url .= '&time;=' . $time; * $url .= '&signature;=' . rawurlencode($signature); * * $curl = curlinit(); * * curlsetopt($curl, CURLOPTURL, 'https://' . $domain . $path . 'index.php?route=api/api' . $url); * curlsetopt($curl, CURLOPTRETURNTRANSFER, 1); * curlsetopt($curl, CURLOPTHEADER, false); * curlsetopt($curl, CURLOPTSSLVERIFYPEER, 0); * curlsetopt($curl, CURLOPTCONNECTTIMEOUT, 30); * curlsetopt($curl, CURLOPTTIMEOUT, 30); * curlsetopt($curl, CURLOPTPOST, 1); * curlsetopt($curl, CURLOPTPOSTFIELDS, $POST); * * $response = curlexec($curl); * * $status = curlgetinfo($curl, CURLINFOHTTPCODE); * * curlclose($curl); * * if ($status == 200) { * $responseinfo = jsondecode($response, true); * } else { * $response_info = []; * } * * @return void */`

Discussion

No comments yet