/**
*	Load XML function
*	Using the $xmlurl variable set above, it creates the basic array used for parsing.
*/
function load_xml()
{
    global $xmlurl, $xml, $array_xml, $arr_attributes, $arr_attributes_master, $updated, $players_online, $xml_age;
    $xml = new XMLToArray($xmlurl, array(), array('server' => '_array_'), TRUE, FALSE);
    $array_xml = $xml->getArray();
    $arr_attributes = $xml->getAttributes();
    // Récupère les attrib de "masterquery" (update timestamp et Players)
    $arr_attributes_master = $arr_attributes[0];
    $arr_attributes_master = $arr_attributes_master['serverlist'];
    $arr_attributes_master = $arr_attributes_master[0];
    // Récupère les attrib de chaque server pour le merge... + simplifie (root du array)
    $arr_attributes = $arr_attributes[1];
    $arr_attributes = $arr_attributes['server'];
    $updated = $arr_attributes_master['mktime'];
    $players_online = $arr_attributes_master['players'];
    $xml_age = mktime() - $updated;
}
 static function fromXml($data)
 {
     $sig = new XMLToArray($data, array(), array(), true, false);
     return $sig->getArray();
 }
示例#3
0
 /**
  * Uploading a video from a url.
  *
  * @param string $url
  * @param string $title the title for the video
  * @param string $description the description for the video
  * @param int|\Profile $profile the size for the video to be encoded, if not specified it will use the vzaar default
  * @param int $bitrate the bitrate for the video to be encoded
  * @param int $width the width for the video to be encoded
  * @param int $replace_id an existing video id to be replaced with the new video
  * @param boolean $transcoding if true forces vzaar to transcode the video, false will use the original source file (only for mp4 and flv files)
  *
  * @return int $video_id returns the video id
  */
 public static function uploadLink($url, $title = NULL, $description = NULL, $profile = Profile::Medium, $bitrate = 256, $width = 200, $replace_id = NULL, $transcoding = false)
 {
     $_url = self::$url . "api/upload/link.xml";
     $signature = Vzaar::getUploadSignature();
     $req = Vzaar::setAuth($_url, 'POST');
     $data = '<?xml version="1.0" encoding="UTF-8"?>
             <vzaar-api>
                 <link_upload>
                     <key>' . $signature['vzaar-api']['key'] . '</key>
                     <guid>' . $signature['vzaar-api']['guid'] . '</guid>
                     <url>' . urlencode($url) . '</url>
                     <encoding_params>
                       <title>' . self::_sanitize_str($title) . '</title>
                       <description>' . self::_sanitize_str($description) . '</description>
                       <size_id>' . $profile . '</size_id>
                       <bitrate>' . $bitrate . '</bitrate>
                       <width>' . $width . '</width>
                       <replace_id>' . $replace_id . '</replace_id>
                       <transcoding>' . $transcoding . '</transcoding>
                     </encoding_params>
                 </link_upload>
             </vzaar-api>';
     $c = new HttpRequest($_url);
     $c->verbose = Vzaar::$enableHttpVerbose;
     $c->method = 'POST';
     array_push($c->headers, $req->to_header());
     array_push($c->headers, 'User-Agent: Vzaar OAuth Client');
     array_push($c->headers, 'Connection: close');
     array_push($c->headers, 'Content-Type: application/xml');
     $reply = $c->send($data);
     $xmlObj = new XMLToArray($reply);
     $arr = $xmlObj->getArray();
     $video_id = $arr['vzaar-api'] ? $arr['vzaar-api']['id'] : false;
     return $video_id;
 }