From 3addc7cd5568244b3a482f96790b7305ca1412e0 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Wed, 22 Apr 2015 16:46:23 +0200 Subject: [PATCH 01/11] Add PHP Publisher for commodity-v2 --- examples/PHP/EDDN.php | 166 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 examples/PHP/EDDN.php diff --git a/examples/PHP/EDDN.php b/examples/PHP/EDDN.php new file mode 100644 index 0000000..533e5e0 --- /dev/null +++ b/examples/PHP/EDDN.php @@ -0,0 +1,166 @@ + 'abcdef0123456789', + * 'softwareName' => 'My Awesome Market Uploader', + * 'softwareVersion' => 'v3.14' + * )); + * + * $result = $eddn->publishCommodityV2( + * 'Eranin', + * 'Azeban Orbital', + * time(), + * array( + * array( + * "name" => "Gold", + * "buyPrice" => 1024, + * "supply" => 7, + * "supplyLevel" => "Low", + * "sellPrice" => 1138, + * "demand" => 42, + * "demandLevel" => "Med" + * ), + * array( + * "name" => "Explosives", + * "buyPrice" => 999, + * "supply" => 1500, + * "supplyLevel" => "Low", + * "sellPrice" => 0, + * "demand" => 0 + * ) + * ) + * ); // return true; + * + **/ + +class EDDN +{ + static private $_debug = true; + + static private $_gateways = array( + 'http://eddn-gateway.elite-markets.net:8080/upload/' + ); + + static private $_schemas = array( + 'commodity-v1' => array( + 'production' => 'http://schemas.elite-markets.net/eddn/commodity/1', + 'test' => 'http://schemas.elite-markets.net/eddn/commodity/1/test' + ), + 'commodity-v2' => array( + 'production' => 'http://schemas.elite-markets.net/eddn/commodity/2', + 'test' => 'http://schemas.elite-markets.net/eddn/commodity/2/test' + ) + ); + + private $_uploaderID = null; + private $_softwareName = null; + private $_softwareVersion = null; + + public function __Construct(array $options) + { + if(array_key_exists('uploaderID', $options)) + $this->setUploaderID($options['uploaderID']); + else + throw new Exception('Option "uploaderID" is required.'); + + if(array_key_exists('softwareName', $options)) + $this->setSoftwareName($options['softwareName']); + else + throw new Exception('Option "softwareName" is required.'); + + if(array_key_exists('softwareVersion', $options)) + $this->setSoftwareVersion($options['softwareVersion']); + else + throw new Exception('Option "softwareVersion" is required.'); + } + + public function publishCommodityV2($systemName, $stationName, $timestamp, array $commodities) + { + $schema = self::$_schemas['commodity-v2'][((self::$_debug === true) ? 'test' : 'production')]; + + $message = array(); + $message['systemName'] = $systemName; + $message['stationName'] = $stationName; + $message['timestamp'] = date('c', $timestamp); + + $message['commodities'] = $commodities; + + return $this->_postToEDDN($schema, $message); + } + + + private function _generateHeader() + { + $header = array(); + + $header['uploaderID'] = $this->getUploaderID(); + $header['softwareName'] = $this->getSoftwareName(); + $header['softwareVersion'] = $this->getSoftwareVersion(); + + return $header; + } + + private function _postToEDDN($schema, array $message) + { + $array = array(); + $array['$schemaRef'] = $schema; + $array['header'] = $this->_generateHeader(); + $array['message'] = $message; + + $json = json_encode($array); + + if(function_exists('curl_version')) + { + $gateway = self::$_gateways[array_rand(self::$_gateways)]; + + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $gateway); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $json); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); + + $result = curl_exec($ch); + curl_close($ch); + unset($ch); + + if($result == 'OK') + return true; + else + return $result; + } + else + throw new Exception('You must have CURL extension in order to publish to EDDN'); + } + + + public function setUploaderID($value) + { + $this->_uploaderID = $value; + } + + public function getUploaderID() + { + return $this->_uploaderID; + } + public function setSoftwareName($value) + { + $this->_softwareName = $value; + } + + public function getSoftwareName() + { + return $this->_softwareName; + } + public function setSoftwareVersion($value) + { + $this->_softwareVersion = $value; + } + + public function getSoftwareVersion() + { + return $this->_softwareVersion; + } +} \ No newline at end of file From 41012f9a9980974f27bb10be763cb185d594f364 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Wed, 22 Apr 2015 16:56:34 +0200 Subject: [PATCH 02/11] Fix indentation --- examples/commodity-v2.0-draft.json | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/commodity-v2.0-draft.json b/examples/commodity-v2.0-draft.json index 68e4819..82a4e4b 100644 --- a/examples/commodity-v2.0-draft.json +++ b/examples/commodity-v2.0-draft.json @@ -10,23 +10,23 @@ "stationName": "Azeban Orbital", "timestamp": "2014-11-17T12:34:56+00:00" "commodities": [ - { - "name": "Gold", - "buyPrice": 1024, - "supply": 7, - "supplyLevel": "Low", - "sellPrice": 1138, - "demand": 42, - "demandLevel": "Med" - }, - { - "name": "Explosives", - "buyPrice": 999, - "supply": 1500, - "supplyLevel": "Low", - "sellPrice": 0, - "demand": 0 - } + { + "name": "Gold", + "buyPrice": 1024, + "supply": 7, + "supplyLevel": "Low", + "sellPrice": 1138, + "demand": 42, + "demandLevel": "Med" + }, + { + "name": "Explosives", + "buyPrice": 999, + "supply": 1500, + "supplyLevel": "Low", + "sellPrice": 0, + "demand": 0 + } ] } } \ No newline at end of file From 335af9ceb87ba50a229e6ef099ef80c9aa2c3c4b Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Wed, 22 Apr 2015 16:58:50 +0200 Subject: [PATCH 03/11] Fix incomplete example --- examples/commodity-v0.1.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/commodity-v0.1.json b/examples/commodity-v0.1.json index dfea54f..3ef668c 100644 --- a/examples/commodity-v0.1.json +++ b/examples/commodity-v0.1.json @@ -11,8 +11,10 @@ "itemName": "Gold", "buyPrice": 1024, "stationStock": 7, + "supplyLevel": "Low", "sellPrice": 1138, "demand": 42, + "demandLevel": "Med" "timestamp": "2014-11-17T12:34:56+00:00" } } \ No newline at end of file From de78a388c006efa2c7f91bc5d58ccb52539b71cc Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Wed, 22 Apr 2015 17:02:45 +0200 Subject: [PATCH 04/11] Added commodity-v1 publish function --- examples/PHP/EDDN.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/examples/PHP/EDDN.php b/examples/PHP/EDDN.php index 533e5e0..3dfa618 100644 --- a/examples/PHP/EDDN.php +++ b/examples/PHP/EDDN.php @@ -7,6 +7,22 @@ * 'softwareVersion' => 'v3.14' * )); * + * $result = $eddn->publishCommodityV1( + * 'Eranin', + * 'Azeban Orbital', + * time(), + * array( + * "itemName" => "Gold", + * "buyPrice" => 1024, + * "supply" => 7, + * "stationStock" => "Low", + * "sellPrice" => 1138, + * "demand" => 42, + * "demandLevel" => "Med" + * ) + * ); // return true; + * + * * $result = $eddn->publishCommodityV2( * 'Eranin', * 'Azeban Orbital', @@ -75,6 +91,21 @@ class EDDN throw new Exception('Option "softwareVersion" is required.'); } + public function publishCommodityV1($systemName, $stationName, $timestamp, array $commodity) + { + $schema = self::$_schemas['commodity-v1'][((self::$_debug === true) ? 'test' : 'production')]; + + $message = array(); + $message['systemName'] = $systemName; + $message['stationName'] = $stationName; + $message['timestamp'] = date('c', $timestamp); + + foreach($commodity AS $key => $value) + $message[$key] = $value; + + return $this->_postToEDDN($schema, $message); + } + public function publishCommodityV2($systemName, $stationName, $timestamp, array $commodities) { $schema = self::$_schemas['commodity-v2'][((self::$_debug === true) ? 'test' : 'production')]; From 515392626e0318e9166516f7fdd7a88727006f56 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Thu, 23 Apr 2015 15:38:47 +0200 Subject: [PATCH 05/11] Added PHP Client --- examples/PHP/Client.bat | 3 + examples/PHP/Client.php | 150 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 examples/PHP/Client.bat create mode 100644 examples/PHP/Client.php diff --git a/examples/PHP/Client.bat b/examples/PHP/Client.bat new file mode 100644 index 0000000..dc20b3f --- /dev/null +++ b/examples/PHP/Client.bat @@ -0,0 +1,3 @@ +"php.exe" -f %~dp0\Client.php + +pause \ No newline at end of file diff --git a/examples/PHP/Client.php b/examples/PHP/Client.php new file mode 100644 index 0000000..4754dd0 --- /dev/null +++ b/examples/PHP/Client.php @@ -0,0 +1,150 @@ +', + FILE_APPEND + ); +} + +// UTC +date_default_timezone_set('UTC'); + +echoLog('Starting EDDN Subscribe'); +echoLog(''); + +$context = new ZMQContext(); +$socket = $context->getSocket(ZMQ::SOCKET_SUB); +$socket->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, ""); +$socket->setSockOpt(ZMQ::SOCKOPT_RCVTIMEO, 600000); + +while (true) +{ + try + { + $socket->connect($relayEDDN); + while (true) + { + $message = $socket->recv(); + + if ($message === false) + { + $socket->disconnect($relayEDDN); + break; + } + + $json = zlib_decode($message); + $array = json_decode($json, true); + $converted = false; + + + // Handle commodity v1 + if($array['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/1') + { + echoLog('Receiving commodity-v1 message...'); + echoLog(' - Converting to v2...'); + + $temp = array(); + $temp['$schemaRef'] = 'http://schemas.elite-markets.net/eddn/commodity/2'; + $temp['header'] = $array['header']; + + $temp['message'] = array(); + $temp['message']['systemName'] = $array['message']['systemName']; + $temp['message']['stationName'] = $array['message']['stationName']; + $temp['message']['timestamp'] = $array['message']['timestamp']; + + $temp['commodities'] = array(); + + $commodity = array(); + + if(array_key_exists('itemName', $temp['message'])) + $commodity['name'] = $temp['message']['itemName']; + + if(array_key_exists('buyPrice', $temp['message'])) + $commodity['buyPrice'] = $temp['message']['buyPrice']; + if(array_key_exists('stationStock', $temp['message'])) + $commodity['supply'] = $temp['message']['stationStock']; + if(array_key_exists('supplyLevel', $temp['message'])) + $commodity['supplyLevel'] = $temp['message']['supplyLevel']; + + if(array_key_exists('sellPrice', $temp['message'])) + $commodity['sellPrice'] = $temp['message']['sellPrice']; + if(array_key_exists('demand', $temp['message'])) + $commodity['demand'] = $temp['message']['demand']; + if(array_key_exists('demandLevel', $temp['message'])) + $commodity['demandLevel'] = $temp['message']['demandLevel']; + + $temp['commodities'][] = $commodity; + $array = $temp; + unset($temp, $commodity); + + $converted = true; + } + + + // Handle commodity v2 + if($array['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/2') + { + if($converted === false) + echoLog('Receiving commodity-v2 message...'); + unset($converted); + + $authorised = false; + $excluded = false; + + if(in_array($array['header']['softwareName'], $authorisedSoftwares)) + $authorised = true; + if(in_array($array['header']['softwareName'], $excludedSoftwares)) + $excluded = true; + + echoLog(' - Software: ' . $array['header']['softwareName'] . ' / ' . $array['header']['softwareVersion']); + echoLog(' - ' . (($authorised === true) + ? 'AUTHORISED' + : (( $excluded === true) ? 'EXCLUDED' : 'UNAUTHORISED') + )); + + if($authorised === true && $excluded === false) + { + // Do what you want with the data... + // Have fun ! + + } + + unset($authorised, $excluded); + } + + echoLog(''); + echoLog(''); + } + } + catch (ZMQSocketException $e) + { + echoLog('ZMQSocketException: ' . $e); + sleep(10); + } +} + +// Exit correctly +exit(0); \ No newline at end of file From ce69c21f291202ffbc1241edc1af51f9de9d8876 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Thu, 23 Apr 2015 16:19:06 +0200 Subject: [PATCH 06/11] Added RegulatedNoise in authorized sample list --- examples/PHP/Client.php | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/PHP/Client.php b/examples/PHP/Client.php index 4754dd0..ef34665 100644 --- a/examples/PHP/Client.php +++ b/examples/PHP/Client.php @@ -7,6 +7,7 @@ $relayEDDN = 'tcp://eddn-relay.elite-markets.net:9500'; // A sample list of authorised softwares $authorisedSoftwares = array( "EliteOCR", + "RegulatedNoise", "Maddavo's Market Share" ); From 43898373f068e022e04fdbc0036df4f543d6d73f Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Thu, 23 Apr 2015 16:46:09 +0200 Subject: [PATCH 07/11] Fix missing message key --- examples/PHP/Client.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/PHP/Client.php b/examples/PHP/Client.php index ef34665..eed6b96 100644 --- a/examples/PHP/Client.php +++ b/examples/PHP/Client.php @@ -76,7 +76,7 @@ while (true) $temp['message']['stationName'] = $array['message']['stationName']; $temp['message']['timestamp'] = $array['message']['timestamp']; - $temp['commodities'] = array(); + $temp['message']['commodities'] = array(); $commodity = array(); @@ -97,8 +97,8 @@ while (true) if(array_key_exists('demandLevel', $temp['message'])) $commodity['demandLevel'] = $temp['message']['demandLevel']; - $temp['commodities'][] = $commodity; - $array = $temp; + $temp['message']['commodities'][] = $commodity; + $array = $temp; unset($temp, $commodity); $converted = true; From ec0692ae7f8110f2ec7adbd60b756ab83fb217ec Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Thu, 23 Apr 2015 17:17:41 +0200 Subject: [PATCH 08/11] Fix inverted $temp/$array --- examples/PHP/Client.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/PHP/Client.php b/examples/PHP/Client.php index eed6b96..4ce9245 100644 --- a/examples/PHP/Client.php +++ b/examples/PHP/Client.php @@ -80,22 +80,22 @@ while (true) $commodity = array(); - if(array_key_exists('itemName', $temp['message'])) - $commodity['name'] = $temp['message']['itemName']; + if(array_key_exists('itemName', $array['message'])) + $commodity['name'] = $array['message']['itemName']; - if(array_key_exists('buyPrice', $temp['message'])) - $commodity['buyPrice'] = $temp['message']['buyPrice']; - if(array_key_exists('stationStock', $temp['message'])) - $commodity['supply'] = $temp['message']['stationStock']; - if(array_key_exists('supplyLevel', $temp['message'])) - $commodity['supplyLevel'] = $temp['message']['supplyLevel']; + if(array_key_exists('buyPrice', $array['message'])) + $commodity['buyPrice'] = $array['message']['buyPrice']; + if(array_key_exists('stationStock', $array['message'])) + $commodity['supply'] = $array['message']['stationStock']; + if(array_key_exists('supplyLevel', $array['message'])) + $commodity['supplyLevel'] = $array['message']['supplyLevel']; - if(array_key_exists('sellPrice', $temp['message'])) - $commodity['sellPrice'] = $temp['message']['sellPrice']; - if(array_key_exists('demand', $temp['message'])) - $commodity['demand'] = $temp['message']['demand']; - if(array_key_exists('demandLevel', $temp['message'])) - $commodity['demandLevel'] = $temp['message']['demandLevel']; + if(array_key_exists('sellPrice', $array['message'])) + $commodity['sellPrice'] = $array['message']['sellPrice']; + if(array_key_exists('demand', $array['message'])) + $commodity['demand'] = $array['message']['demand']; + if(array_key_exists('demandLevel', $array['message'])) + $commodity['demandLevel'] = $array['message']['demandLevel']; $temp['message']['commodities'][] = $commodity; $array = $temp; From 0a5f7b3d1e79ddad79a032694b431dbf640afd08 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Fri, 24 Apr 2015 12:07:39 +0200 Subject: [PATCH 09/11] Made PHP client logs prettier ! --- examples/PHP/Client.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/examples/PHP/Client.php b/examples/PHP/Client.php index 4ce9245..191ac7d 100644 --- a/examples/PHP/Client.php +++ b/examples/PHP/Client.php @@ -3,29 +3,51 @@ * Configuration */ $relayEDDN = 'tcp://eddn-relay.elite-markets.net:9500'; +$logFile = dirname(__FILE__) . '/Logs_EDDN_' . date('Y-m-d') . '.htm'; // A sample list of authorised softwares $authorisedSoftwares = array( + "ED-TD.SPACE", "EliteOCR", "RegulatedNoise", + "RegulatedNoise__DJ", "Maddavo's Market Share" ); // Used this to excludes yourself for example has you don't want to handle your own messages ^^ $excludedSoftwares = array( - 'ED-TD.SPACE' + 'My Awesome Market Uploader' ); /** * START */ +$oldTime = false; function echoLog($str) { + global $oldTime, $logFile; + + if(!file_exists($logFile)) + { + file_put_contents( + $logFile, + '' + ); + } + + if($oldTime != date('H:i:s') || $oldTime === false) + { + $oldTime = date('H:i:s'); + $str = $oldTime . ' | ' . $str; + } + else + $str = ' ' . ' | ' . $str; + fwrite(STDOUT, $str . PHP_EOL); file_put_contents( - dirname(__FILE__) . '/Log_EDDN_' . date('Y-m-d') . '.htm', - $str . '
', + $logFile, + $str . PHP_EOL, FILE_APPEND ); } From 8600488c6ce77feae168d0972b70f3c2d691d0a5 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Fri, 24 Apr 2015 16:00:45 +0200 Subject: [PATCH 10/11] Use stdClass instead of arrays --- examples/PHP/EDDN.php | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/examples/PHP/EDDN.php b/examples/PHP/EDDN.php index 3dfa618..7b72316 100644 --- a/examples/PHP/EDDN.php +++ b/examples/PHP/EDDN.php @@ -95,13 +95,13 @@ class EDDN { $schema = self::$_schemas['commodity-v1'][((self::$_debug === true) ? 'test' : 'production')]; - $message = array(); - $message['systemName'] = $systemName; - $message['stationName'] = $stationName; - $message['timestamp'] = date('c', $timestamp); + $message = new stdClass(); + $message->systemName = $systemName; + $message->stationName = $stationName; + $message->timestamp = date('c', $timestamp); foreach($commodity AS $key => $value) - $message[$key] = $value; + $message->{$key} = $value; return $this->_postToEDDN($schema, $message); } @@ -110,12 +110,12 @@ class EDDN { $schema = self::$_schemas['commodity-v2'][((self::$_debug === true) ? 'test' : 'production')]; - $message = array(); - $message['systemName'] = $systemName; - $message['stationName'] = $stationName; - $message['timestamp'] = date('c', $timestamp); + $message = new stdClass(); + $message->systemName = $systemName; + $message->stationName = $stationName; + $message->timestamp = date('c', $timestamp); - $message['commodities'] = $commodities; + $message->commodities = $commodities; return $this->_postToEDDN($schema, $message); } @@ -123,23 +123,22 @@ class EDDN private function _generateHeader() { - $header = array(); - - $header['uploaderID'] = $this->getUploaderID(); - $header['softwareName'] = $this->getSoftwareName(); - $header['softwareVersion'] = $this->getSoftwareVersion(); + $header = new stdClass(); + $header->uploaderID = $this->getUploaderID(); + $header->softwareName = $this->getSoftwareName(); + $header->softwareVersion = $this->getSoftwareVersion(); return $header; } - private function _postToEDDN($schema, array $message) + private function _postToEDDN($schema, stdClass $message) { - $array = array(); - $array['$schemaRef'] = $schema; - $array['header'] = $this->_generateHeader(); - $array['message'] = $message; + $object = new stdClass(); + $object->{'$schemaRef'} = $schema; + $object->header = $this->_generateHeader(); + $object->message = $message; - $json = json_encode($array); + $json = json_encode($object); if(function_exists('curl_version')) { From 0d805340f7dad02e48498046db4e7a5b2b2f6690 Mon Sep 17 00:00:00 2001 From: AnthorNet Date: Fri, 24 Apr 2015 16:03:33 +0200 Subject: [PATCH 11/11] Revert "Use stdClass instead of arrays" This reverts commit 8600488c6ce77feae168d0972b70f3c2d691d0a5. --- examples/PHP/EDDN.php | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/examples/PHP/EDDN.php b/examples/PHP/EDDN.php index 7b72316..3dfa618 100644 --- a/examples/PHP/EDDN.php +++ b/examples/PHP/EDDN.php @@ -95,13 +95,13 @@ class EDDN { $schema = self::$_schemas['commodity-v1'][((self::$_debug === true) ? 'test' : 'production')]; - $message = new stdClass(); - $message->systemName = $systemName; - $message->stationName = $stationName; - $message->timestamp = date('c', $timestamp); + $message = array(); + $message['systemName'] = $systemName; + $message['stationName'] = $stationName; + $message['timestamp'] = date('c', $timestamp); foreach($commodity AS $key => $value) - $message->{$key} = $value; + $message[$key] = $value; return $this->_postToEDDN($schema, $message); } @@ -110,12 +110,12 @@ class EDDN { $schema = self::$_schemas['commodity-v2'][((self::$_debug === true) ? 'test' : 'production')]; - $message = new stdClass(); - $message->systemName = $systemName; - $message->stationName = $stationName; - $message->timestamp = date('c', $timestamp); + $message = array(); + $message['systemName'] = $systemName; + $message['stationName'] = $stationName; + $message['timestamp'] = date('c', $timestamp); - $message->commodities = $commodities; + $message['commodities'] = $commodities; return $this->_postToEDDN($schema, $message); } @@ -123,22 +123,23 @@ class EDDN private function _generateHeader() { - $header = new stdClass(); - $header->uploaderID = $this->getUploaderID(); - $header->softwareName = $this->getSoftwareName(); - $header->softwareVersion = $this->getSoftwareVersion(); + $header = array(); + + $header['uploaderID'] = $this->getUploaderID(); + $header['softwareName'] = $this->getSoftwareName(); + $header['softwareVersion'] = $this->getSoftwareVersion(); return $header; } - private function _postToEDDN($schema, stdClass $message) + private function _postToEDDN($schema, array $message) { - $object = new stdClass(); - $object->{'$schemaRef'} = $schema; - $object->header = $this->_generateHeader(); - $object->message = $message; + $array = array(); + $array['$schemaRef'] = $schema; + $array['header'] = $this->_generateHeader(); + $array['message'] = $message; - $json = json_encode($object); + $json = json_encode($array); if(function_exists('curl_version')) {