public function fetch() {
		if ( $this->fetcher === null )
			throw new Exception( "not initialized" );
		
		$xmlString = $this->fetcher->getCollectionListXML_asString();
		$xml = simpleXML_load_string( $xmlString );
		$this->list = $xml->xpath( "//collection" );
	}
Example #2
0
 private function parser($xmlstring)
 {
     $flag = false;
     $data = array();
     // check xml format
     if ($this->checkXmlFormat($xmlstring)) {
         $flag = true;
         // xml to object
         $data = simpleXML_load_string($xmlstring, 'SimpleXMLElement', LIBXML_NOCDATA);
         // object to array
         $this->objectToArray($data);
     }
     return array($flag, $data);
 }
Example #3
0
 /**
  * Convenience function, download XML from URL, return it in a string
  * @return string - XML downloaded from the parsed URL
  */
 protected static final function getXml($url)
 {
     // Since we must use curl, initialise its handler
     $ch = curl_init();
     // Setup curl with our options
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $url);
     // Get the source with curl
     $source = curl_exec($ch);
     if (curl_errno($ch)) {
         die("{\"error\":\"" . curl_error($ch) . "\"}");
     } else {
         // Get HTTP response code to check for issues
         $h = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         if (StatusCodes::isError($h) || !StatusCodes::canHaveBody($h)) {
             $err = StatusCodes::httpHeaderFor($h);
             header($err);
             die("{\"error\":\"" . $err . "\"}");
         }
     }
     // Close up curl, no longer needed
     curl_close($ch);
     // Read the XML string into an object
     $xml = simpleXML_load_string($source);
     // Return it
     return $xml;
 }
Example #4
0
<div id="main" class="flickr">
	<?php 
$user = sql_query('SELECT * FROM ' . DB_PREFIX . 'user WHERE administrator = "1"');
$user = mysql_fetch_array($user);
$photoid = $user['photo'];
$data = file_get_contents("http://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=3df15beb1f581eda361ca6806fce63b5&user_id=" . $user['photo'] . "&per_page=32");
$object = simpleXML_load_string($data);
$photo = $object->photos->photo;
echo '<ul class="photos">';
foreach ($photo as $each) {
    $photo_m = 'http://farm' . $each['farm'] . '.static.flickr.com/' . $each['server'] . '/' . $each['id'] . '_' . $each['secret'] . '_m.jpg';
    $photo_b = 'http://farm' . $each['farm'] . '.static.flickr.com/' . $each['server'] . '/' . $each['id'] . '_' . $each['secret'] . '_b.jpg';
    echo '<li>';
    echo '<a href="' . $photo_b . '" class="lightbox"><img src="' . $photo_m . '" /></a>';
    echo '</li>';
}
echo '</ul>';
?>
</div>