Exemple #1
0
 public function getResourcesForTag($tag)
 {
     if ($DEBUGMODEON) {
         echo "Entered getresourcesForTag, flickr plugin<br>";
     }
     //Getting the tag label
     $tagtosearch = $tag->getLabel();
     //Retrieving photo
     $Photo = $this->FlickrLib->photos_search(array("tags" => $tagtosearch, "sort" => 'relevance', 'per_page' => '30'));
     //if no picture found...
     if (count($Photo['photo']) == 0) {
         return array();
     }
     //Building resource objects
     foreach ($Photo["photo"] as $singlepic) {
         $TempRes = new Result();
         $TempRes->setUrl("http://www.flickr.com/photos/" . $singlepic['owner'] . "/" . $singlepic['id']);
         $TempRes->setTitle($singlepic["title"]);
         $TempRes->setShownContent($this->FlickrLib->buildPhotoURL($singlepic, "Square"));
         $TempRes->setDescription("");
         $TempRes->setTagSearched($tag);
         $TempRes->setContentType(1);
         //images
         $ResourceBundle[] = $TempRes;
     }
     return $ResourceBundle;
 }
Exemple #2
0
 public function getResourcesForTag($tag)
 {
     global $PluginConf;
     $tagValue = $tag->getLabel();
     $Bundle = array();
     $Cachedir = $PluginConf[$this->_UNIQUE_NUMBER]['cachedir'];
     //We are using the lastRSS library to to the job
     $rss = new lastRSS();
     $rss->cache_dir = $Cachedir;
     $rss->cache_time = 360;
     // 3 minutes
     $rss->items_limit = 10;
     //Loading RSS
     if ($Feed = $rss->get($PluginConf[$this->_UNIQUE_NUMBER]['rssurl'] . $tagValue)) {
         foreach ($Feed['items'] as $Result) {
             $Res = new Result();
             $Res->setTitle(html_entity_decode($Result['title']));
             $Res->setDescription(html_entity_decode($Result['description']));
             $Res->setUrl($Result['link']);
             $Res->setShownContent($Result['link']);
             $Res->setTagSearched($tag);
             $Res->setContentType(2);
             $Bundle[] = $Res;
         }
     } else {
         die('Error: RSS file not found...');
     }
     return $Bundle;
 }
Exemple #3
0
 public function getResourcesForTag($tag)
 {
     //Getting the tag label
     $tagtosearch = $tag->getLabel();
     $tagendpoint = 'http://www.connotea.org/data/bookmarks/tag/';
     $tagendpoint .= $tagtosearch;
     $ch = curl_init($tagendpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_USERPWD, $this->_username . ":" . $this->_password);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     $xmldoc = curl_exec($ch);
     curl_close($ch);
     if (empty($xmldoc)) {
         return array();
     }
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = false;
     //Loading the XML doc
     $doc->LoadXML($xmldoc);
     $xpath = new DOMXPath($doc);
     //registering the namespace
     $defnamespace = $doc->documentElement->lookupnamespaceURI("dcterms");
     $xpath->registerNamespace('dcterms', $defnamespace);
     //Extracting result information
     $query = '//dcterms:URI';
     $entries = $xpath->query($query);
     if ($entries->length == 0) {
         return array();
     }
     //We obtained the main entry for each resul. now we have to check
     foreach ($entries as $entry) {
         $TempRes = new Result();
         $TempRes->setUrl($entry->getElementsByTagName('link')->item(0)->nodeValue);
         $TempRes->setTitle($entry->getElementsByTagName('title')->item(0)->nodeValue);
         $TempRes->setShownContent($entry->getElementsByTagName('link')->item(0)->nodeValue);
         $TempRes->setDescription("");
         $TempRes->setTagSearched($tag);
         $TempRes->setContentType(0);
         //text
         $ResourceBundle[] = $TempRes;
     }
     return $ResourceBundle;
 }
Exemple #4
0
 public function getResourcesForTag($tag)
 {
     //Getting the tag label
     $tagtosearch = $tag->getLabel();
     //Before everything else, we have to retrieve TAG ID from the tag name
     $tagresendpoint = 'http://www.43things.com/service/get_tags_goals?id=';
     $tagresendpoint .= $tagtosearch;
     $tagresendpoint .= '&api_key=' . $this->_APIKEY;
     $ch = curl_init($tagresendpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $xmldoc = curl_exec($ch);
     curl_close($ch);
     //43Things will return an empty page on no match
     if (empty($xmldoc)) {
         return array();
     }
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = false;
     //Loading the XML doc
     $doc->LoadXML($xmldoc);
     $xpath = new DOMXPath($doc);
     //WE HAVE TO SETUP THINGS TO USE THE DEFAULT NAMESPACE
     $defnamespace = $doc->documentElement->lookupnamespaceURI(NULL);
     $xpath->registerNamespace('m', $defnamespace);
     //Extracting tag information
     $query = '/m:feed/m:goal';
     $entries = $xpath->query($query);
     if (empty($entries)) {
         return array();
     }
     foreach ($entries as $entry) {
         $TempRes = new Result();
         $TempRes->setUrl($entry->getElementsByTagName('link')->item(0)->getAttribute('href'));
         $TempRes->setTitle($entry->getElementsByTagName('name')->item(0)->nodeValue);
         $TempRes->setShownContent($TempRes->getUrl());
         $TempRes->setDescription('');
         $TempRes->setTagSearched($tag);
         $TempRes->setContentType(0);
         //text
         $ResourceBundle[] = $TempRes;
     }
     return $ResourceBundle;
 }
Exemple #5
0
 public function getResourcesForTag($tag)
 {
     //Getting the tag label
     $tagtosearch = $tag->getLabel();
     //We simply query the right page and get back a JSON result.
     $tagendpoint = 'http://gdata.youtube.com/feeds/videos/-/';
     $tagendpoint .= $tagtosearch;
     $tagendpoint .= '?alt=json&orderby=viewCount';
     $ch = curl_init($tagendpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $Jsonresult = curl_exec($ch);
     curl_close($ch);
     //TODO error handling
     //Decoding json answer
     $results = json_decode($Jsonresult);
     $entries = $results->feed->entry;
     //TODO better error handling
     if (empty($entries)) {
         return array();
     }
     foreach ($entries as $entry) {
         $TempRes = new Result();
         $TempRes->setUrl($entry->link[1]->href);
         $t = '$t';
         $TempRes->setTitle($entry->title->{$t});
         $mediadesc = 'media$description';
         $mediagroup = 'media$group';
         $mediathumb = 'media$thumbnail';
         $TempRes->setDescription($entry->{$mediagroup}->{$mediadesc}->{$t});
         $thumbarr = $entry->{$mediagroup}->{$mediathumb};
         $TempRes->setShownContent($thumbarr[0]->url);
         $TempRes->setTagSearched($tag);
         $TempRes->setContentType(1);
         //text
         $ResourceBundle[] = $TempRes;
     }
     return $ResourceBundle;
 }
Exemple #6
0
 public function getResourcesForTag($tag)
 {
     //Getting the tag label
     $tagtosearch = $tag->getLabel();
     //Before everything else, we have to retrieve TAG ID from the tag name
     $tagendpoint = 'http://www.vinorati.com/tag/';
     $tagendpoint .= $tagtosearch;
     //retrieve the results page
     $ch = curl_init($tagendpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $resdoc = curl_exec($ch);
     curl_close($ch);
     if (empty($resdoc)) {
         return array();
     }
     //Ok, we have to parse this document via regexp. i know i know, but no api was available.
     preg_match_all("#<li[^\">]+class=\"textwine\"><a[^\"]+\"(.*)\">(.*)</a>[^<]+</li>#Ui", $resdoc, $entries);
     //array 0 is the address, array 2 the name of the wine
     if (empty($entries[1])) {
         return array();
     }
     //Building the result set
     $mycounter = 0;
     foreach ($entries[1] as $entry) {
         $TempRes = new Result();
         $TempRes->setUrl($entry);
         $TempRes->setTitle($entries[2][$mycounter]);
         $TempRes->setShownContent($entries[2][$mycounter]);
         $TempRes->setDescription("");
         $TempRes->setTagSearched($tag);
         $TempRes->setContentType(0);
         //text
         $ResourceBundle[] = $TempRes;
         $mycounter++;
     }
     return $ResourceBundle;
 }
Exemple #7
0
 public function getResourcesForTag($tag)
 {
     //Getting the tag label
     $tagtosearch = $tag->getLabel();
     //Before everything else, we have to retrieve TAG ID from the tag name
     $tagbynameendpoint = 'http://www.zvents.com/rest/tag_by_name/';
     $tagbynameendpoint .= $tagtosearch;
     $tagbynameendpoint .= '?key=' . $this->_APIKEY;
     $ch = curl_init($tagbynameendpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $xmldoc = curl_exec($ch);
     curl_close($ch);
     if (empty($xmldoc)) {
         return array();
     }
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = false;
     //Loading the XML doc
     $doc->LoadXML($xmldoc);
     $xpath = new DOMXPath($doc);
     //Extracting tag information
     $query = '//tag';
     $entries = $xpath->query($query);
     if ($entries->length == 0) {
         return array();
     }
     $tagid = $entries->item(0)->getAttributeNode('id')->nodeValue;
     //We can now query for related events
     $taginfoendpoint = 'http://www.zvents.com/rest/tag_events/';
     $taginfoendpoint .= $tagid;
     //query has to be done using the tag
     $taginfoendpoint .= '?key=' . $this->_APIKEY;
     //Curl init
     $ch = curl_init($taginfoendpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $xmldoc = curl_exec($ch);
     curl_close($ch);
     //DOC init
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = false;
     //Loading the XML doc
     $doc->LoadXML($xmldoc);
     $xpath = new DOMXPath($doc);
     //Extracting tag information
     $query = '//event';
     $entries = $xpath->query($query);
     //TODO better error handling
     if (empty($entries)) {
         return array();
     }
     foreach ($entries as $entry) {
         $TempRes = new Result();
         $TempRes->setUrl($entry->getElementsByTagName('link')->item(0)->nodeValue);
         $TempRes->setTitle($entry->getElementsByTagName('name')->item(0)->nodeValue);
         $TempRes->setShownContent($entry->getElementsByTagName('link')->item(0)->nodeValue);
         $TempRes->setDescription($entry->getElementsByTagName('description')->item(0)->nodeValue);
         $TempRes->setTagSearched($tag);
         $TempRes->setContentType(0);
         //text
         $ResourceBundle[] = $TempRes;
     }
     return $ResourceBundle;
 }