/** * Ensures that imageSearch() throws an exception when the coloration option is invalid * * @return void */ public function testImageSearchExceptionColorationInvalid() { try { $this->_yahoo->imageSearch('php', array('coloration' => 'oops')); $this->fail('Expected Zend_Service_Exception not thrown'); } catch (Zend_Service_Exception $e) { $this->assertContains("option 'coloration'", $e->getMessage()); } }
/** * Ensures that imageSearch() throws an exception when the adult_ok option is invalid * * @return void */ public function testImageSearchExceptionAdultOkInvalid() { try { $this->_yahoo->imageSearch('php', array('adult_ok' => -1)); $this->fail('Expected Zend_Service_Exception not thrown'); } catch (Zend_Service_Exception $e) { $this->assertContains('error occurred sending request', $e->getMessage()); } }
echo $_SERVER['SCRIPT_NAME']; ?> " method="post"> <p> <label>Search For: <input type="text" name="search_term" value="<?php echo htmlspecialchars($keywords, ENT_QUOTES); ?> "></label> <input type="submit" value="Search!"> </p> </form> <?php if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $yahoo = new Zend_Service_Yahoo('zendtesting'); try { $results = $yahoo->imageSearch($keywords, array("results" => 5)); if ($results->totalResults() > 0) { echo '<div id="image">'; echo '<h2>Image Search Results</h2>'; foreach ($results as $result) { echo "<a href='{$result->ClickUrl}' title='{$result->Title}'><img src='{$result->Thumbnail->Url->getUri()}'></a>"; } echo '</div>'; } $results = $yahoo->webSearch($keywords); if ($results->totalResults() > 0) { echo '<div id="web">'; echo '<h2>Web Search Results</h2>'; foreach ($results as $result) { echo "<h3><a href='{$result->ClickUrl}'>{$result->Title}</a></h3>"; echo "<p>{$result->Summary} <br> [<a href='{$result->CacheUrl}'>Cached Version</a>]</p>";