<?php

/*

Livechatoo JS init example:

livechatoo.embed.init({account : '...', custom : 'PHPSESSID=82d76f892ca5935e9952822b01adc597&param2=value2&param3=value3'}) 

note: values (82d76f892ca5935e9952822b01adc597, value2, ...) should be encoded

*/

parse_str($_GET['custom'], $parse_str);

/*

print_r($parse_str);
Array
(
    [PHPSESSID] => 82d76f892ca5935e9952822b01adc597
    [param2] => value2
    [param3] => value3
)

- by $parse_str['PHPSESSID'] verify session
- your API reply example: name1=value1&name2=value2,... (names and values must be encoded)
- if your script is not in UTF-8, names and values must be converted to UTF-8 before encoding:
  urlencode(iconv('your_encoding', 'utf-8', 'názov alebo hodnota'));
- reply limit is 300 bytes

*/


// not logged in
if (!$logged) {
  
$reply[] = urlencode('Logged in?').'='.urlencode('No');
}

// logged in
else {
  
$reply[] = urlencode('Logged in?').'='.urlencode('Yes');
  
$reply[] = urlencode('Customer ID').'='.urlencode('00054912');
  
$reply[] = urlencode('Email').'='.urlencode('customer@email.com');
  
$reply[] = urlencode('Unpaid invoices').'=3x'// :-)
}

echo 
implode('&'$reply);

/*

note:
- result example when user is logged in: http://www.livechatoo.com/other/api_url/api_result.png
- it is recommended to fill API URL in with "https"
- Livechatoo does not store your API results

*/

?>