Skip to content

Instantly share code, notes, and snippets.

@nickgs
Last active August 21, 2019 15:44
Show Gist options
  • Save nickgs/89f99e0c92ac2afd5ffff56d11b4f9fd to your computer and use it in GitHub Desktop.
Save nickgs/89f99e0c92ac2afd5ffff56d11b4f9fd to your computer and use it in GitHub Desktop.
ADC Product API PHP Curl Example
<?php
$product = "700-11ABK";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.adctoday.com/api/v1/product/{$product}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => array(
"Accept: */*",
"Accept-Encoding: gzip, deflate",
"Cache-Control: no-cache",
"Connection: keep-alive",
"Host: www.adctoday.com",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment