Beispiel #1
0
<?php

require_once "FlickrClient.php";
session_start();
ob_start();
$api_key = $_SESSION["key"];
ob_end_flush();
$text = $_GET["text"];
$small_image = array();
$medium_image = array();
$large_image = array();
$id = array();
$flicker_client = new FlickrClient($api_key);
$res_xml = $flicker_client->PhotoSearch($text);
$special = array('&lt;', '&quot;', '&gt;');
$replace = array('<', '"', '>');
$str = str_replace($special, $replace, $res_xml);
$xml = <<<XML
<?xml version="1.0"?>
{$str}
XML;
file_put_contents("/tmp/xml.txt", $xml);
$XML = new SimpleXMLElement($xml);
foreach ($XML->photos->photo as $photo) {
    $image_id = (string) $photo['id'];
    array_push($id, $image_id);
    $server_id = (string) $photo['server'];
    $farm_id = (string) $photo['farm'];
    $secret = (string) $photo['secret'];
    $medium_url = "http://farm{$farm_id}.static.flickr.com/{$server_id}/{$image_id}_{$secret}_m.jpg";
    array_push($medium_image, $medium_url);