Examples Updated
jay
I have added example code to the web search, video search and the image search.
If you look at the code for each example you'll see that they all share a common structure:
Include the phpYahoo.php file
PHP:
-
include_once('api/phpYahoo.php');
Instantiate a new phpYahoo class
PHP:
-
$y = new phpYahoo('YAHOOAPPID');
Get the search keyword(s) and create an array of parameters
PHP:
-
$keyword = $_GET['keyword'];
Call the webSearch function and get the results
PHP:
-
$results = $y->searchWeb($params);
Loop through the results and assign it to a variable as HTML
PHP:
-
foreach($results as $result) {
-
$html .= "<h3><a href='".$result['clickUrl']."' title='".$result['displayUrl']."'>".$result['title']."</a></h3>";
-
$html .= $result['summary'];
-
$html .= "<br>";
-
}
Add a FORM to search from
HTML:
Display the results
PHP:
Posted in phpYahoo, Documentation, Source Code, Example |
No Comments »






