Class for fetching and sending data between http://www.directo.ee/ API. This class includes pulling data from Directo and posting xml with php array to xml generation.
Source code viewer
<?php /** * @file Directo import class. * * @author Ra Mänd <ram4nd@gmail.com> * @link http://browse-tutorials.com/ * @tutorial http://browse-tutorials.com/snippet/directo-class * * Example: * require_once 'directo.php' * $directo = new directo('[https://directo.gate.ee/xmlcore/TYPE/xmlcore.asp]', '[Your Key]'); * $response = $directo->curl_get_xml_object( * 'what', * date('d.m.Y', date('yesterday')) * ); */ class directo { private $url; private $key; public function __construct($url, $key) { $this->url = $url; } /** * @param $what * @param $ts * * @return SimpleXMLElement */ public function curl_get_xml_object($what, $ts) { 'get' => 1, 'what' => $what, 'ts' => $ts, ))); // Curl request to receive the xml. } /** * @param $what * @param $xml_array * * @return void */ public function curl_post($what, $xml_array) { $xml = '<?xml version="1.0" encoding="utf-8"?>'."\n". $this->_format_xml_elements($xml_array); 'put' => 1, 'what' => $what, 'xmldata' => $xml, ), null, '&'); // Curl request to receive the xml. } private function _error($msg) { } private function _format_xml_elements($array) { $output = ''; foreach ($array as $key => $value) { if ($value['key']) { $output .= ' <' . $value['key']; $output .= $this->_attributes($value['attributes']); } $output .= '>' . (is_array($value['value']) ? $this->_format_xml_elements($value['value']) : $this->_check_plain($value['value'])) . '</' . $value['key'] . ">\n"; } else { $output .= " />\n"; } } } else { $output .= ' <' . $key . '>' . (is_array($value) ? $this->_format_xml_elements($value) : $this->_check_plain($value)) . "</$key>\n"; } } return $output; } foreach ($attributes as $attribute => &$data) { $data = $attribute . '="' . $this->_check_plain($data) . '"'; } } private function _check_plain($text) { } } Programming Language: PHP