}
+ /**
+ * @brief Build the post xml
+ *
+ * @param string $type The message type
+ * @param array $message The message data
+ *
+ * @return string The post XML
+ */
+ public static function build_post_xml($type, $message) {
+
+ $data = array("XML" => array("post" => array($type => $message)));
+ return xml::from_array($data, $xml);
+ }
+
/**
* @brief Builds and transmit messages
*
*/
private function build_and_transmit($owner, $contact, $type, $message, $public_batch = false, $guid = "", $spool = false) {
- $data = array("XML" => array("post" => array($type => $message)));
-
- $msg = xml::from_array($data, $xml);
+ $msg = build_post_xml($type, $message);
logger('message: '.$msg, LOGGER_DATA);
logger('send guid '.$guid, LOGGER_DEBUG);
$user = $r[0];
$status = diaspora::build_status($item[0], $user);
- $data = array("XML" => array("post" => array($status["type"] => $status["message"])));
- $xml = xml::from_array($data, $xmlobj);
+ $xml = diaspora::build_post_xml($status["type"], $status["message"]);
// Send the envelope
header("Content-Type: application/magic-envelope+xml; charset=utf-8");
echo diaspora::build_magic_envelope($xml, $user);
- //header("Content-Type: application/xml; charset=utf-8");
- //echo $xml;
- //killme();
-
killme();
}
$user = $r[0];
$status = diaspora::build_status($item[0], $user);
- $data = array("XML" => array("post" => array($status["type"] => $status["message"])));
- $xml = xml::from_array($data, $xmlobj);
+ $xml = diaspora::build_post_xml($status["type"], $status["message"]);
header("Content-Type: application/xml; charset=utf-8");
echo $xml;