<?php

function addTicket($transaction_id){
    $data = array(
        'transaction_id' => 'f323982jr23h4fc247224',
        'items' => array(array(
            'service_code'  =>1,
            'item_type'     => 'ticket',
            'item_code'     => 9,
            'quantity'      => 1
        ))
    );
//$func->prnt(json_encode($data),true);

    $xml = '<TransactionViewModel xmlns="http://schemas.datacontract.org/2004/07/JsonRestService.Model">
              <items>
                <TransactionItemViewModel>
                  <item_code>1</item_code>
                  <item_type>Bilet</item_type>
                  <quantity>2</quantity>
                  <service_code>4</service_code>
                </TransactionItemViewModel>
              </items>
              <transaction_id>f24232o2uf92jef9s8ysdf</transaction_id>
            </TransactionViewModel>';

    $curl = curl_init('http://185.126.217.55/api/codes');
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER,
        array("Content-type: application/json"));
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
    $results = curl_exec($curl);
    curl_close($curl);
    echo '<pre>';print_r($results);
}