Exemplo n.º 1
0
 public function testFromXML()
 {
     $xml = simplexml_load_string('<video>
                                     <id>208359</id>
                                     <type><![CDATA[audio]]></type>
                                     <title><![CDATA[Ex-bondscoach Blangé bij Langs de Lijn]]></title>
                                     <description><![CDATA[De volleybalbond en mannenbondscoach Peter Blangé hebben tussentijds afscheid van elkaar genomen. Langs de Lijn-presentator Robbert Meeder vraagt studiogast Blangé naar het waarom van de breuk.]]></description>
                                     <published><![CDATA[2010-12-29 22:52:00]]></published>
                                     <last_update><![CDATA[2010-12-29 23:00:09]]></last_update>
                                     <thumbnail><![CDATA[]]></thumbnail>
                                     <link><![CDATA[http://nos.nl/audio/208359-exbondscoach-blange-bij-langs-de-lijn.html]]></link>
                                     <embedcode><![CDATA[<object width="550" height="309"><param name="movie" value="http://s.nos.nl/swf/embed/nos_partner_video.swf?tcmid=tcm-5-870639&platform=open&partner=speeltuin"></param><param name="wmode" value="transparent"></param><param name="allowScriptAccess" value="always"></param><param name="allowfullscreen" value="true"></param><embed src="http://s.nos.nl/swf/embed/nos_partner_video.swf?tcmid=tcm-5-870639&platform=open&partner=speeltuin" type="application/x-shockwave-flash" wmode="transparent" width="550" height="309" allowfullscreen="true" allowScriptAccess="always"></embed></object>]]></embedcode>
                                     <keywords><keyword><![CDATA[Volleybal]]></keyword><keyword><![CDATA[Peter Blangé]]></keyword></keywords></video>');
     $audio = Audio::fromXML($xml);
     $this->assertEquals($audio->getId(), '208359');
     $this->assertEquals($audio->getTitle(), 'Ex-bondscoach Blangé bij Langs de Lijn');
     $this->assertEquals($audio->getDescription(), 'De volleybalbond en mannenbondscoach Peter Blangé hebben tussentijds afscheid van elkaar genomen. Langs de Lijn-presentator Robbert Meeder vraagt studiogast Blangé naar het waarom van de breuk.');
     $this->assertEquals($audio->getPublished('d-m-Y G:i:s'), '29-12-2010 22:52:00');
     $this->assertEquals($audio->getLastUpdate('d-m-Y G:i:s'), '29-12-2010 23:00:09');
     $this->assertEquals($audio->getThumbnailXS(), '');
     $this->assertEquals($audio->getThumbnailS(), '');
     $this->assertEquals($audio->getThumbnailM(), '');
     $this->assertEquals($audio->getLink(), 'http://nos.nl/audio/208359-exbondscoach-blange-bij-langs-de-lijn.html');
     $this->assertEquals($audio->getKeywords(), array('Volleybal', 'Peter Blangé'));
     $this->assertEquals($audio->getEmbedCode(), '<object width="550" height="309"><param name="movie" value="http://s.nos.nl/swf/embed/nos_partner_video.swf?tcmid=tcm-5-870639&platform=open&partner=speeltuin"></param><param name="wmode" value="transparent"></param><param name="allowScriptAccess" value="always"></param><param name="allowfullscreen" value="true"></param><embed src="http://s.nos.nl/swf/embed/nos_partner_video.swf?tcmid=tcm-5-870639&platform=open&partner=speeltuin" type="application/x-shockwave-flash" wmode="transparent" width="550" height="309" allowfullscreen="true" allowScriptAccess="always"></embed></object>');
 }
Exemplo n.º 2
0
 /**
  * Get the latest audio for the specified category
  *
  * @param string $category
  * @return array
  */
 public function getLatestAudio($category = self::NEWS)
 {
     $url = 'http://open.nos.nl/v2/latest/audio/key/' . $this->apikey . '/output/xml/category/' . $category . '/';
     $audios = array();
     $xml = $this->request($url);
     foreach ($xml->audio as $audio) {
         $audios[] = Audio::fromXML($audio);
     }
     return $audios;
 }
Exemplo n.º 3
0
 /**
  * Create an Audio object from XML
  *
  * @param SimpleXMLElement $xml simpleXML element containing a single audio XML
  *
  * @static
  *
  * @return phpOpenNOS\Model\Audio
  */
 public static function fromXML(\SimpleXMLElement $xml)
 {
     $audio = new Audio();
     $audio->setId((int) $xml->id);
     $audio->setTitle((string) $xml->title);
     $audio->setDescription((string) $xml->description);
     $audio->setPublished((string) $xml->published);
     $audio->setLastUpdate((string) $xml->last_update);
     $audio->setThumbnailXS((string) $xml->thumbnail_xs);
     $audio->setThumbnailS((string) $xml->thumbnail_s);
     $audio->setThumbnailM((string) $xml->thumbnail_m);
     $audio->setLink((string) $xml->link);
     $audio->setEmbedCode((string) $xml->embedcode);
     $keywords = array();
     foreach ($xml->keywords->keyword as $keyword) {
         $keywords[] = (string) $keyword;
     }
     $audio->setKeywords($keywords);
     return $audio;
 }