/**
  * Expand shortened Flickr links to image thumbnails if Flickr API key is set
  * @param $api_key Flickr API key
  */
 public function expandFlickrThumbnails($api_key)
 {
     $logger = Logger::getInstance();
     $link_dao = DAOFactory::getDAO('LinkDAO');
     //Flickr thumbnails
     $logger->setUsername(null);
     $fa = new FlickrAPIAccessor($api_key);
     $flickrlinkstoexpand = $link_dao->getLinksToExpandByURL('http://flic.kr/');
     if (count($flickrlinkstoexpand) > 0) {
         $logger->logUserInfo(count($flickrlinkstoexpand) . " Flickr links to expand.", __METHOD__ . ',' . __LINE__);
     } else {
         $logger->logUserInfo("There are no Flickr thumbnails to expand.", __METHOD__ . ',' . __LINE__);
     }
     $total_thumbnails = 0;
     $total_errors = 0;
     foreach ($flickrlinkstoexpand as $fl) {
         $eurl = $fa->getFlickrPhotoSource($fl);
         if ($eurl["expanded_url"] != '') {
             $link_dao->saveExpandedUrl($fl, $eurl["expanded_url"], '', 1);
             $total_thumbnails = $total_thumbnails + 1;
         } elseif ($eurl["error"] != '') {
             $link_dao->saveExpansionError($fl, $eurl["error"]);
             $total_errors = $total_errors + 1;
         }
         $logger->logUserSuccess($total_thumbnails . " Flickr thumbnails expanded (" . $total_errors . " errors)", __METHOD__ . ',' . __LINE__);
     }
 }
 public function crawl()
 {
     $config = Config::getInstance();
     $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO');
     $options = $plugin_option_dao->getOptionsHash('flickrthumbnails', true);
     $api_key = $options['flickr_api_key']->option_value;
     if (isset($api_key) && $api_key != '') {
         $logger = Logger::getInstance();
         $fa = new FlickrAPIAccessor($api_key);
         $ldao = DAOFactory::getDAO('LinkDAO');
         $flickrlinkstoexpand = $ldao->getLinksToExpandByURL('http://flic.kr/');
         if (count($flickrlinkstoexpand > 0)) {
             $logger->logStatus(count($flickrlinkstoexpand) . " Flickr links to expand", "Flickr Plugin");
         } else {
             $logger->logStatus("No Flickr links to expand", "Flickr Plugin");
         }
         foreach ($flickrlinkstoexpand as $fl) {
             $eurl = $fa->getFlickrPhotoSource($fl);
             if ($eurl["expanded_url"] != '') {
                 $ldao->saveExpandedUrl($fl, $eurl["expanded_url"], '', 1);
             } elseif ($eurl["error"] != '') {
                 $ldao->saveExpansionError($fl, $eurl["error"]);
             }
         }
         $logger->close();
         # Close logging
     }
 }
 function crawl()
 {
     global $db;
     global $conn;
     $config = Config::getInstance();
     $api_key = $config->getValue('flickr_api_key');
     if (isset($api_key) && $api_key != '') {
         $logger = Logger::getInstance();
         $fa = new FlickrAPIAccessor($api_key);
         $ldao = DAOFactory::getDAO('LinkDAO');
         $flickrlinkstoexpand = $ldao->getLinksToExpandByURL('http://flic.kr/');
         if (count($flickrlinkstoexpand > 0)) {
             $logger->logStatus(count($flickrlinkstoexpand) . " Flickr links to expand", "Flickr Plugin");
         } else {
             $logger->logStatus("No Flickr links to expand", "Flickr Plugin");
         }
         foreach ($flickrlinkstoexpand as $fl) {
             $eurl = $fa->getFlickrPhotoSource($fl);
             if ($eurl["expanded_url"] != '') {
                 $ldao->saveExpandedUrl($fl, $eurl["expanded_url"], '', 1);
             } elseif ($eurl["error"] != '') {
                 $ldao->saveExpansionError($fl, $eurl["error"]);
             }
         }
         $logger->close();
         # Close logging
     }
 }
 /**
  * Expand shortened Flickr links to image thumbnails if Flickr API key is set
  * @param $api_key Flickr API key
  */
 public function expandFlickrThumbnails($api_key)
 {
     $logger = Logger::getInstance();
     $link_dao = DAOFactory::getDAO('LinkDAO');
     //Flickr thumbnails
     $logger->setUsername(null);
     $flickr_api = new FlickrAPIAccessor($api_key);
     $flickr_links_to_expand = $link_dao->getLinksToExpandByURL('http://flic.kr/');
     if (count($flickr_links_to_expand) > 0) {
         $logger->logUserInfo(count($flickr_links_to_expand) . " Flickr links to expand.", __METHOD__ . ',' . __LINE__);
     } else {
         $logger->logUserInfo("There are no Flickr thumbnails to expand.", __METHOD__ . ',' . __LINE__);
     }
     $total_thumbnails = 0;
     $total_errors = 0;
     foreach ($flickr_links_to_expand as $flickr_link) {
         $photo_details = $flickr_api->getFlickrPhotoSource($flickr_link);
         if ($photo_details["image_src"] != '') {
             //@TODO Make another Flickr API call to get the photo title & description and save to tu_links
             $link_dao->saveExpandedUrl($flickr_link, $flickr_link, '', $photo_details["image_src"]);
             $total_thumbnails = $total_thumbnails + 1;
         } elseif ($photo_details["error"] != '') {
             $link_dao->saveExpansionError($flickr_link, $photo_details["error"]);
             $total_errors = $total_errors + 1;
         }
     }
     $logger->logUserSuccess($total_thumbnails . " Flickr thumbnails expanded (" . $total_errors . " errors)", __METHOD__ . ',' . __LINE__);
 }
Example #5
0
function flickrthumbnails_crawl()
{
    global $THINKTANK_CFG;
    global $db;
    global $conn;
    if (isset($THINKTANK_CFG['flickr_api_key']) && $THINKTANK_CFG['flickr_api_key'] != '') {
        $logger = new Logger($THINKTANK_CFG['log_location']);
        $fa = new FlickrAPIAccessor($THINKTANK_CFG['flickr_api_key'], $logger);
        $ldao = new LinkDAO($db, $logger);
        $flickrlinkstoexpand = $ldao->getLinksToExpandByURL('http://flic.kr/');
        if (count($flickrlinkstoexpand > 0)) {
            $logger->logStatus(count($flickrlinkstoexpand) . " Flickr links to expand", "Flickr Plugin");
        } else {
            $logger->logStatus("No Flickr links to expand", "Flickr Plugin");
        }
        foreach ($flickrlinkstoexpand as $fl) {
            $eurl = $fa->getFlickrPhotoSource($fl);
            if ($eurl["expanded_url"] != '') {
                $ldao->saveExpandedUrl($fl, $eurl["expanded_url"], '', 1);
            } elseif ($eurl["error"] != '') {
                $ldao->saveExpansionError($fl, $eurl["error"]);
            }
        }
        $logger->close();
        # Close logging
    }
}
 public function testGetFlickrPhotoSourceSuccess()
 {
     $logger = Logger::getInstance();
     $fa = new FlickrAPIAccessor('dummykey', $logger);
     $this->assertTrue(isset($fa));
     $eurl = $fa->getFlickrPhotoSource('http://flic.kr/p/7QAWC7');
     $this->assertEqual($eurl["expanded_url"], 'http://farm3.static.flickr.com/2755/4488149974_04d9558212_m.jpg');
     $logger->close();
 }
 public function testGetFlickrPhotoSourceSuccess()
 {
     $logger = Logger::getInstance();
     $flickr_api = new FlickrAPIAccessor('dummykey', $logger);
     $this->assertTrue(isset($flickr_api));
     $photo_details = $flickr_api->getFlickrPhotoSource('http://flic.kr/p/7QAWC7');
     $this->assertEqual($photo_details["image_src"], 'http://farm3.static.flickr.com/2755/4488149974_04d9558212_m.jpg');
     $logger->close();
 }
 function testGetFlickrPhotoSourceSuccess()
 {
     global $THINKUP_CFG;
     $logger = new Logger($THINKUP_CFG['log_location']);
     $fa = new FlickrAPIAccessor('dummykey', $logger);
     $this->assertTrue(isset($fa));
     $eurl = $fa->getFlickrPhotoSource('http://flic.kr/p/7QAWC7');
     $this->assertEqual($eurl["expanded_url"], 'http://farm3.static.flickr.com/2755/4488149974_04d9558212_m.jpg');
     $logger->close();
 }
Example #9
0
 function testGetFlickrPhotoSource()
 {
     global $THINKTANK_CFG;
     $logger = new Logger($THINKTANK_CFG['log_location']);
     $fa = new FlickrAPIAccessor($THINKTANK_CFG['flickr_api_key'], $logger);
     $this->assertTrue(isset($fa));
     $eurl = $fa->getFlickrPhotoSource('http://flic.kr/p/7QAWC7');
     $this->assertEqual($eurl["expanded_url"], 'http://farm3.static.flickr.com/2755/4488149974_04d9558212_m.jpg');
     $eurl = $fa->getFlickrPhotoSource('http://flic.kr/p/6YS7AE');
     $this->assertEqual($eurl["expanded_url"], '');
     $this->assertEqual($eurl["error"], 'Photo not found');
     $logger->close();
 }
    public function crawl() {
        $config = Config::getInstance();

        $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO');
        $options = $plugin_option_dao->getOptionsHash('flickrthumbnails', true);
        $api_key = '';
        if (isset($options['flickr_api_key']->option_value)) {
            $api_key =  $options['flickr_api_key']->option_value;
        }

        if (isset($api_key) && $api_key != '') {
            $logger = Logger::getInstance();
            $logger->setUsername(null);
            $fa = new FlickrAPIAccessor($api_key);
            $ldao = DAOFactory::getDAO('LinkDAO');

            $flickrlinkstoexpand = $ldao->getLinksToExpandByURL('http://flic.kr/');
            if (count($flickrlinkstoexpand) > 0) {
                $logger->logUserInfo(count($flickrlinkstoexpand)." Flickr links to expand.",  __METHOD__.','.__LINE__);
            } else {
                $logger->logUserInfo("There are no Flickr thumbnails to expand.",  __METHOD__.','.__LINE__);
            }

            $total_thumbnails = 0;
            $total_errors = 0;
            foreach ($flickrlinkstoexpand as $fl) {
                $eurl = $fa->getFlickrPhotoSource($fl);
                if ($eurl["expanded_url"] != '') {
                    $ldao->saveExpandedUrl($fl, $eurl["expanded_url"], '', 1);
                    $total_thumbnails = $total_thumbnails + 1;
                } elseif ($eurl["error"] != '') {
                    $ldao->saveExpansionError($fl, $eurl["error"]);
                    $total_errors = $total_errors + 1;
                }
                $logger->logUserSuccess($total_thumbnails." Flickr thumbnails expanded (".$total_errors." errors)",
                __METHOD__.','.__LINE__);
            }
        }
    }
Example #11
0
 /**
  * Expand shortened Flickr links to image thumbnails if Flickr API key is set.
  * @param $api_key Flickr API key
  * @param $flickr_link Flickr URL
  */
 public function expandFlickrThumbnail($api_key, $flickr_link, $original_link)
 {
     $flickr_api = new FlickrAPIAccessor($api_key);
     $photo_details = $flickr_api->getFlickrPhotoSource($flickr_link);
     if ($photo_details["image_src"] != '') {
         //@TODO Make another Flickr API call to get the photo title & description and save to tu_links
         $this->link_dao->saveExpandedUrl($original_link, $flickr_link, '', $photo_details["image_src"]);
     } elseif ($photo_details["error"] != '') {
         $this->link_dao->saveExpansionError($original_link, $photo_details["error"]);
     }
 }