/**
  * Basic testing to ensure that tagSearch() works as expected
  *
  * @return void
  */
 public function testTagSearchBasic()
 {
     $this->_flickr->getRestClient()->getHttpClient()->setAdapter($this->_httpClientAdapterTest);
     $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));
     $options = array('per_page' => 10, 'page' => 1, 'tag_mode' => 'or', 'extras' => 'license, date_upload, date_taken, owner_name, icon_server');
     $resultSet = $this->_flickr->tagSearch('php', $options);
     $this->assertEquals(4285, $resultSet->totalResultsAvailable);
     $this->assertEquals(10, $resultSet->totalResults());
     $this->assertEquals(10, $resultSet->totalResultsReturned);
     $this->assertEquals(1, $resultSet->firstResultPosition);
     $this->assertEquals(0, $resultSet->key());
     try {
         $resultSet->seek(-1);
     } catch (OutOfBoundsException $e) {
         $this->assertContains('Illegal index', $e->getMessage());
     }
     $resultSet->seek(9);
     try {
         $resultSet->seek(10);
     } catch (OutOfBoundsException $e) {
         $this->assertContains('Illegal index', $e->getMessage());
     }
     $resultSet->rewind();
     $resultSetIds = array('428222530', '427883929', '427884403', '427887192', '427883923', '427884394', '427883930', '427884398', '427883924', '427884401');
     $this->assertTrue($resultSet->valid());
     foreach ($resultSetIds as $resultSetId) {
         $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__ . "-result_{$resultSetId}"));
         $result = $resultSet->current();
         $this->assertTrue($result instanceof Zend_Service_Flickr_Result);
         $resultSet->next();
     }
     $this->assertFalse($resultSet->valid());
 }
    /**
     * Ensures that tagSearch() works as expected with the sort option
     *
     * @return void
     */
    public function testTagSearchOptionSort()
    {
        $options = array(
            'per_page' => 10,
            'page'     => 1,
            'tag_mode' => 'or',
            'sort'     => 'date-taken-asc',
            'extras'   => 'license, date_upload, date_taken, owner_name, icon_server'
            );

        $resultSet = $this->_flickr->tagSearch('php', $options);

        $this->assertTrue(10 < $resultSet->totalResultsAvailable);
        $this->assertEquals(10, $resultSet->totalResults());
        $this->assertEquals(10, $resultSet->totalResultsReturned);
        $this->assertEquals(1, $resultSet->firstResultPosition);

        foreach ($resultSet as $result) {
            $this->assertTrue($result instanceof Zend_Service_Flickr_Result);
            if (isset($dateTakenPrevious)) {
                $this->assertTrue(strcmp($result->datetaken, $dateTakenPrevious) > 0);
            }
            $dateTakenPrevious = $result->datetaken;
        }
    }
Exemple #3
0
 function index()
 {
     iG_Zend::load("Zend.Service.Flickr");
     $flickr = new Zend_Service_Flickr('55f19b1be9c7f496fe33b45d1915fa03');
     $this->results = $flickr->tagSearch("PHPSP");
     $this->layout = 'igrape';
 }
Exemple #4
0
 /**
  * Ensures that tagSearch() throws an exception when an option is invalid
  *
  * @return void
  */
 public function testTagSearchExceptionOptionInvalid()
 {
     try {
         $this->_flickr->tagSearch('irrelevant', array('unexpected' => null));
         $this->fail('Expected Zend_Service_Exception not thrown');
     } catch (Zend_Service_Exception $e) {
         $this->assertContains('parameters are invalid', $e->getMessage());
     }
 }
Exemple #5
0
 /**
  *  @group ZF-6397
  */
 function testTotalForEmptyResultSet()
 {
     $this->assertEquals(0, $this->_flickr->tagSearch('zendflickrtesttagnoresults')->totalResults());
 }
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 Zend_Service_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);
                sort($widths);
                $max_height = array_pop($heights);
 public function vxFlickrBoardBlock($tag = 'beauty', $width = 1024, $colspan = 4)
 {
     switch ($width) {
         case 800:
             $b = 4;
             break;
         case 640:
             $b = 3;
             break;
         case 1024:
         default:
             $b = 7;
             break;
         case 1280:
             $b = 9;
             break;
         case 1400:
         case 1600:
         case 1920:
         case 2560:
             $b = 10;
             break;
     }
     $Flickr = new Zend_Service_Flickr(FLICKR_API_KEY);
     $_photos = $Flickr->tagSearch($tag);
     if (count($_photos) > 0) {
         $f = '';
         $f .= '<tr><td align="left" class="hf" colspan="' . $colspan . '" style="border-top: 1px solid #EEE;">';
         $f .= '<a href="http://www.flickr.com/photos/tags/' . $tag . '" target="_blank"><img src="/img/flickr_logo.gif" border="0" align="absmiddle" /></a>&nbsp;&nbsp;&nbsp;<span class="tip_i">These photos are taken by various authors on <a href="http://www.flickr.com/" target="_blank" class="regular">Flickr</a> and sharing under a Creative Commons license.</span>';
         $f .= '</td></tr>';
         $f .= '<tr><td align="left" class="hf" colspan="' . $colspan . '">';
         $i = 0;
         foreach ($_photos as $Photo) {
             $i++;
             if ($i > $b) {
                 break;
             }
             $url = Image::vxFlickrImageURL($Photo->Square->uri);
             if (isset($Photo->Medium->clickUri)) {
                 $f .= '<a href="' . $Photo->Medium->clickUri . '" class="friend" target="_blank"><img src="' . $url["img"] . '" align="absmiddle" class="portrait" /><br /><small>';
                 if (mb_strlen($Photo->title, 'UTF-8') > 10) {
                     $f .= mb_substr($Photo->title, 0, 10, 'UTF-8') . ' ...';
                 } else {
                     $f .= $Photo->title;
                 }
                 $f .= '</small></a>';
             } else {
                 $f .= '<a href="' . $Photo->Square->clickUri . '" class="friend" target="_blank"><img src="' . $url["img"] . '" align="absmiddle" class="portrait" /><br /><small>';
                 if (mb_strlen($Photo->title, 'UTF-8') > 10) {
                     $f .= mb_substr($Photo->title, 0, 10, 'UTF-8') . ' ...';
                 } else {
                     $f .= $Photo->title;
                 }
                 $f .= '</small></a>';
             }
         }
         $f .= '</td></tr>';
         $f .= '<tr><td align="left" class="hf" colspan="' . $colspan . '"><span class="tip_i">Thanks them for sharing these great moments, for more great shots please visit <a href="http://www.flickr.com/" target="_blank" class="regular">Flickr.com</a> <img src="/img/fico_flickr.gif" align="absmiddle" border="0" /></span></td></tr>';
     } else {
         $f = '';
         $f .= '<tr><td align="left" class="hf" colspan="' . $colspan . '" style="border-top: 1px solid #EEE;">';
         $f .= '<a href="http://www.flickr.com/photos/tags/' . $tag . '" target="_blank"><img src="/img/flickr_logo.gif" border="0" align="absmiddle" /></a>&nbsp;&nbsp;&nbsp;<span class="tip_i">' . Vocabulary::site_name . ' 支持从 Flickr 聚合照片!想让你的照片显示在这?给照片加上 [ ' . $tag . ' ] 标签即可。</span>';
         $f .= '</td></tr>';
     }
     return $f;
 }
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service_Flickr
 * @subpackage Demos
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
/**
 * Query Flickr for a tag and display all of the photos for
 * that tag.
 */
error_reporting(E_ALL);
/**
 * @see Zend_Service_Flickr
 */
require_once 'Zend/Service/Flickr.php';
$flickr = new Zend_Service_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";
}
Exemple #9
0
                        </div>
                    </div>
                </div>

                <div class="flexible">
                    <div id="mainContentView" class="frameLayout">
                        <div id="albumListView" class="scrollView top">
                            <div class="scroller">
                                <div id="albumList" class="tableLayout fixed navigatable">
                                    <?php 
foreach ($tags as $tag) {
    ?>
                                    <?php 
    if (!($photos[$tag] = $cache->load($tag))) {
        $photos[$tag] = array();
        $results = $flickr->tagSearch($tag, array('sort' => 'interestingness-desc', 'per_page' => 50));
        foreach ($results as $result) {
            $photos[$tag][] = array('title' => $result->title, 'square' => $result->Square->uri, 'thumbnail' => $result->Thumbnail->uri);
        }
        $cache->save($photos[$tag], $tag);
    }
    ?>
                                    <a href="#viewPhotos/album/<?php 
    echo $tag;
    ?>
">
                                        <span style="width: 75px">
                                            <img width="75" height="75" alt="<?php 
    echo $photos[$tag][0]['title'];
    ?>
" src="<?php 
Exemple #10
0
 function testzendframe()
 {
     $this->load->library('zend');
     $this->zend->load('Zend/Service/Flickr');
     $flickr = new Zend_Service_Flickr('c2f9d353e3fcaffb3db32e6254940ff8');
     $results = $flickr->tagSearch('human');
     $tvalue = '';
     foreach ($results as $result) {
         $tvalue .= $result->title . '<br />';
     }
     //$this->zend->load('Zend/Service/Twitter');
     //$twitter = new Zend_Service_Twitter('somushiv', 'Factor8');
     //$res = $twitter->account->verifyCredentials();
     $data = array('one' => $tvalue, 'two' => '$res');
     //$response = $twitter->account->endSession();
     $this->template->write_view('content', 'members/form_member', $data, TRUE);
     $this->template->render();
 }