Skip to content

@ydn /gist:242381
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
<?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.