예제 #1
0
 /**
  * Utility method that saves an HTTP response to a file
  *
  * @param  string $name
  * @return void
  */
 protected function saveResponse($name)
 {
     file_put_contents("{$this->filesPath}/{$name}.response", $this->flickr->getRestClient()->getHttpClient()->getLastResponse()->asString());
 }
예제 #2
0
 /**
  *  @group ZF-6397
  */
 public function testTotalForEmptyResultSet()
 {
     $this->assertEquals(0, $this->flickr->tagSearch('zendflickrtesttagnoresults')->totalResults());
 }
예제 #3
0
파일: Result.php 프로젝트: navassouza/zf2
 /**
  * Parse the Flickr Result
  *
  * @param  DOMElement $image
  * @param  Flickr     $flickr Original Flickr object with which the request was made
  */
 public function __construct(DOMElement $image, Flickr $flickr)
 {
     $xpath = new DOMXPath($image->ownerDocument);
     foreach ($xpath->query('./@*', $image) as $property) {
         $this->{$property->name} = (string) $property->value;
     }
     $this->flickr = $flickr;
     foreach ($this->flickr->getImageDetails($this->id) as $k => $v) {
         $this->{$k} = $v;
     }
 }
예제 #4
0
    <h1>Flickr Compositor</h1>
    <form action="<?php 
echo $_SERVER['SCRIPT_NAME'];
?>
" method="post">
        <p>
            <label>Search For: <input type="text" name="search_term" value="<?php 
echo $keywords;
?>
"></label>
            <input type="submit" value="Search!" onclick='this.value="Please Wait..."'>
        </p>
    </form>
<?php 
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
    $flickr = new Flickr('381e601d332ab5ce9c25939570cb5c4b');
    try {
        $results = $flickr->tagSearch($keywords, array('per_page' => 50, 'tag_mode' => 'all'));
        if ($results->totalResults() > 0) {
            $images = array();
            foreach ($results as $result) {
                if (isset($result->Medium)) {
                    $images[] = imagecreatefromjpeg($result->Medium->uri);
                    $heights[] = $result->Medium->height;
                    $widths[] = $result->Medium->width;
                }
            }
            if (sizeof($images) == 0) {
                echo '<p style="color: orange; font-weight: bold">No Results Found.</p>';
            } else {
                sort($heights);
예제 #5
0
파일: flickr-search.php 프로젝트: raZ3l/zf2
<?php

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 * @package   Zend_Service
 */
use Zend\Loader\StandardAutoloader;
use Zend\Service\Flickr\Exception\ExceptionInterface as FlickrException;
use Zend\Service\Flickr\Flickr;
/**
 * Query Flickr for a tag and display all of the photos for
 * that tag.
 */
error_reporting(E_ALL);
require_once dirname(dirname(dirname(dirname(__DIR__)))) . '/library/Zend/Loader/StandardAutoloader.php';
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
$flickr = new Flickr('your api key here');
$photos = $flickr->tagSearch('php');
foreach ($photos as $photo) {
    echo '<img src="' . $photo->Thumbnail->uri . '" /> <br />';
    echo $photo->title . "<br /> \n";
}