Skip to content

Instantly share code, notes, and snippets.

@kulor
Created February 3, 2009 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kulor/57535 to your computer and use it in GitHub Desktop.
Save kulor/57535 to your computer and use it in GitHub Desktop.
<?php
class Yql extends Controller {
function __construct()
{
parent::Controller();
$this->load->library('yql_lib');
}
function index()
{
echo '<ul>';
echo '<li><a href="search_twitter/@kulor">Search Twitter for "@kulor"</a></li>';
echo '<li><a href="search_flickr/kulor">Search Flickr for "kulor"</a></li>';
echo '<li><a href="search_yahoo/kulor">Search Yahoo for "kulor"</a></li>';
echo '<li><a href="search_wikipedia/open">Search Wikipedia for "open"</a></li>';
echo '</ul>';
}
function geo_test()
{
echo '<pre>';
print_r($this->yql_lib->test_query());
}
function search_twitter($term = '@kulor')
{
echo '<pre>';
$yql_query = 'select * from json where url="http://search.twitter.com/search.json?q=' . $term . '" and itemPath = "json.results"';
print_r($this->yql_lib->query($yql_query));
}
function search_flickr($term = 'kulor')
{
echo '<pre>';
$yql_query = 'select * from flickr.photos.search where text="' . $term . '" limit 10';
print_r($this->yql_lib->query($yql_query));
}
function search_yahoo($term = 'kulor')
{
echo '<pre>';
$yql_query = 'select title,abstract from search.web where query="' . $term . '"';
print_r($this->yql_lib->query($yql_query));
}
function search_wikipedia($term = 'open')
{
echo '<pre>';
$yql_query = 'select * from xml where url="http://en.wikipedia.org/w/api.php?action=opensearch&search=' . $term . '&format=xml" and itemPath = "SearchSuggestion.Section.Item"';
print_r($this->yql_lib->query($yql_query));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment