Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

YML, YQL, PHP, CSS, and HTML for YAP app search box referenced in YDN blog post: http://developer.yahoo.net/blog/archives/2009/11/yahoo_app_searchbox.html

View gist:242381
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
<?php
$search_term = $_GET['search_term'];
if($search_term){
//http://developer.yahoo.com/yql/console/?q=select%20*%20from%20search.web%20where%20query%3D%22pizza%22
$yql_search_url = "http://query.yahooapis.com/v1/public/yql?"
."q=select%20*%20from%20search.web%20where%20query%3D%22$search_term%22&"
."format=json&diagnostics=false&callback=";
$ch = curl_init($yql_search_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$response = json_decode(curl_exec($ch));
curl_close($ch);
}
?>
 
<? if($response->query->results->result): ?>
<ul id="results">
<? foreach($response->query->results->result as $result): ?>
<li>
<a href="<?= $result->clickUrl ?>"><?= $result->title ?></a><br/>
<?= $result->abstract ?>
</li>
<? endforeach ?>
</ul>
<? else: ?>
<style>
#wrapper ul {
padding-left: 0px;
}
#wrapper ul li {
margin-bottom: 1ex;
}
</style>
<div id="wrapper">
<yml:form replace="results">
<input name="search_term"/>
<input type="submit" value="Search"/>
</yml:form>
<ul id="results"></ul>
</div>
<? endif ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.