Promotion Items - מחירי מוצרים המקושרים למבצעים

Get the products items related with a promotion given chain_id, store_id and promotion_id. Note that the amount of products can be quite large. Accordingly you may want to use this function only when user or app actually need the data. 

 

Request parameters: 

"chain_id"

"store_id"

"promotion_id"

Sample code: 
<php

$params = array(
    "api_key" => "API_KEY", // or "access_token" => "some-token"
    "chain_id" => "7290492000005",
    "store_id" => "501",
    "promotion_id" => "12995348",
);
$url = "http://api.priceli.co.il/v1/priceli/promotion-items";
$response = curlGET($url, $params);
$data = json_decode($response);
echoResponse($response);

if ($data->status == 1) {
    //do something with product data

} else if ($data->status == 2) {
    //no data! do something

} else {
    echo "Error occur: " . $data->message;
}

function echoResponse($response){
    echo '<html><head><meta charset="UTF-8"></head><body>';
    echo $response;
    echo '</body></html>';
}

function curlGET($url, $data, &$errorBuf = null) {
    if ($data == null) {
        $data = array();
    }
    $url = $url . "?" . http_build_query($data);

    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => $url,
    ));
    $response = curl_exec($curl);
    if (!$response) {
        $response = false;
        if ($errorBuf != null) {
            $errorBuf = curl_error($curl);
        }
    }
    curl_close($curl);
    return $response;
}

?>

Sample Response : 
{
  "status": 1,
  "count": 1,
  "total": 1,
  "pageLimit": -1,
  "pageNum": -1,
  "data": [
    {
      "id": "66",
      "chain_id": "7290492000005",
      "store_id": "501",
      "promotion_id": "12995348",
      "item_code": "7290000042855",
      "item_type": "1",
      "is_gift_item": "0",
      "sys_updated_date": "2015-11-10 12:59:51",
      "sys_updated_date_sec": "1447153191"
    }
  ]
}