PROBLEM There were no documentation for use of Rest by Curl and Rest with Java use. SOLVED Adding Classes to help to use Rest by Curl and Adding samples to use Rest with Java.
35 lines
735 B
PHP
35 lines
735 B
PHP
<?php
|
|
|
|
require_once("FormatedMessage.php");
|
|
|
|
//Class defined to be instanced and handle XML format messages.
|
|
class XmlMessage extends FormatedMessage
|
|
{
|
|
//call the parent Curl initialization and set the type of the message
|
|
public function XmlMessage()
|
|
{
|
|
parent::__construct();
|
|
$this->type = "xml";
|
|
}
|
|
//Format the array parameter to a xml valid format. TODO: Need to find out a better way to do it.
|
|
protected function format( array $message)
|
|
{
|
|
if ( empty( $message) )
|
|
{
|
|
return ;
|
|
}
|
|
if ( is_array( $message) )
|
|
{
|
|
$xml = "<?xml version='1.0'?><request>";
|
|
foreach( $message as $index => $data)
|
|
{
|
|
$xml .= "<".$index.">".$data."</".$index.">";
|
|
}
|
|
$xml .= "</request>";
|
|
}
|
|
return $xml;
|
|
}
|
|
}
|
|
|
|
?>
|