Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Order Desk API: Get Inventory Items
//Order Desk API: Get Inventory Items
//To get your Store ID and API Key, go to Order Desk > Settings > Advanced
$store_id = 0;
$api_key = "";
//Setup cURL Variables
$url = "";
$headers = array(
"ORDERDESK-STORE-ID: {$store_id}",
"ORDERDESK-API-KEY: {$api_key}",
"Content-Type: application/json",
//Setup cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
//Send To Order Desk and Parse Response
$response = trim(curl_exec($ch));
$info = curl_getinfo($ch);
$json = json_decode($response, 1);
//Not Valid JSON?
if (!is_array($json)) {
echo "<b>Non-JSON Return:</b><br>";
echo $response;
//Show Response
echo "<b>Order Response:</b><br>";
echo "<pre>" . print_r($json, 1) . "</pre>";
//Show cuRL Connection Details
echo "<b>cURL Response:</b><br>";
echo "<pre>" . print_r($info, 1) . "</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment