function index() { iG_Zend::load("Zend.Service.Flickr"); $flickr = new Zend_Service_Flickr('55f19b1be9c7f496fe33b45d1915fa03'); $this->results = $flickr->tagSearch("PHPSP"); $this->layout = 'igrape'; }
/** * * @param string $apiKey Flickr api key. If not given, it will try to find it in config. */ public function __construct($apiKey = null) { if (null === $apiKey) { $apiKey = Centurion_Config_Manager::get('flickr.apikey'); } parent::__construct($apiKey); }
/** * 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; } }
/** * tampilkan form di index */ public function indexAction() { $fetchForm = new Pluto_Form_Flickr_Userfetch(); $this->view->fetchForm = $fetchForm; $request = $this->getRequest(); if ($this->getRequest()->isPost()) { if ($fetchForm->isValid($request->getPost())) { $email = $fetchForm->getValue('email'); $apikey = Zend_Registry::get('config')->flickr->apikey; $flickr = new Zend_Service_Flickr($apikey); /** * @TODO nyari cara klo ada error : username not found */ $hasil = $flickr->userSearch($email); $this->view->hasilFetch = $hasil; } } }
/** * @group ZF-6397 */ function testTotalForEmptyResultSet() { $this->assertEquals(0, $this->_flickr->tagSearch('zendflickrtesttagnoresults')->totalResults()); }
/** * 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()); }
<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 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);
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> <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> <span class="tip_i">' . Vocabulary::site_name . ' 支持从 Flickr 聚合照片!想让你的照片显示在这?给照片加上 [ ' . $tag . ' ] 标签即可。</span>'; $f .= '</td></tr>'; } return $f; }
/** * Parse the Flickr Result * * @param DOMElement $image * @param Zend_Service_Flickr $flickr Original Zend_Service_Flickr object with which the request was made * @return void */ public function __construct(DOMElement $image, Zend_Service_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; } }
* 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"; }
<?php include 'init.php'; define('FRAMEWORK_PATH', '../../framework/'); $mootoolsScripts = (include '../blank/mootools_files.php'); $flickr = new Zend_Service_Flickr('60b877f55da92e05b809c8d0c055ff05'); $tags = array('singapore', 'dog', 'computer'); $photos = array(); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no;" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <meta name="apple-touch-fullscreen" content="yes" /> <title>Photo Gallery</title> <link href="../blank/favicon.png" rel="shortcut icon" type="image/x-icon" /> <link href="../blank/app_icon.png" rel="apple-touch-icon" /> <link href="../blank/app_startup.png" rel="apple-touch-startup-image" /> <link href="themes/sample.css" media="screen" rel="stylesheet" type="text/css" /> <?php foreach ($mootoolsScripts as $package => $files) { ?> <?php foreach ($files as $file) {
public function updateData($import = false) { // Fetch the data from twitter $user_id = $this->getProperty('user_id'); $username = $this->getProperty('username'); // fetch the API key from config $config = Zend_Registry::get('configuration'); $key = $config->flickr->api_key; $count = $import ? 250 : 100; $pages = $import ? 10 : 1; if (!$user_id) { $flickr = new Zend_Service_Flickr($key); $user_id = $flickr->getIdByUsername($username); $this->setProperty('user_id', $user_id); } $total = array(); for ($page = 1; $page <= $pages; $page++) { if (!($photos = $this->fetchFlickrPage($key, $user_id, $count, $page))) { break; } $total = array_merge($total, $photos); if (count($photos) < $count) { break; } } // Mark as updated (could have been with errors) $this->markUpdated(); // Return number of new items return $total; }
/** * Parse the Flickr Result * * @param DomElement $image * @param Zend_Service_Flickr $flickr Original Zend_Service_Flickr object with which the request was made */ function __construct(DomElement $image, Zend_Service_Flickr $flickr) { $xpath = new DOMXPath($image->ownerDocument); $photo_properties = array('id', 'owner', 'secret', 'server', 'title', 'ispublic', 'isfriend', 'isfamily', 'license', 'date_upload', 'date_taken', 'owner_name', 'icon_server'); 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; } }
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(); }