<< Back to previous view

[ZF-2358] Zend_Service_Yahoo::webSearch 'site' option Created: 27/Dec/07  Updated: 22/Jun/09

Status: Open
Project: Zend Framework
Component/s: Zend_Service_Yahoo
Affects Version/s: 1.0.3
Fix Version/s: Next Mini Release

Type: Bug Priority: Major
Reporter: Jonathan Maron Assignee: Simone Carletti
Resolution: Unresolved Votes: 2
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags:
Participants: Jonathan Maron, Kevin Golding, Milan Momcilovic, Sergei Izvorean, Simone Carletti and Wil Sinclair
Fix Version Priority: Should Have

 Description   
The 'site' option of Zend_Service_Yahoo::webSearch does not work. Whenever it is specified, nothing is returned.

For example, when searching for "mysql" on "www.php.net", many results are returned:

http://search.yahoo.com/search;_ylt=A0geu9VfanRHn3MApo1XNyoA?p=site%3Awww.php.net+mysql&y=Search&fr=sfp&ei=UTF-8

Similarly, calling the REST API directly returns results:

http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YAHOO_ID&query=mysql&results=10&site=www.php.net

However, doing the same with "Zend Framework 1.0.3", nothing is returned.

Using PEAR's Services_Yahoo_Search component, the results are returned correctly.

Sample Code:

// ----------------------------------------------------------------------

// Zend Framework 1.0.3

include_once 'Zend/Service/Yahoo.php';

$yahoo = new Zend_Service_Yahoo('YAHOO_ID');

$results = $yahoo->webSearch('mysql', array('site' => 'www.php.net'));

foreach ($results as $result)
{
    echo $result->Title . '<br />';
}

echo "<hr />";

// ----------------------------------------------------------------------

// PEAR

include_once 'Services/Yahoo/Search.php';

$yahoo = Services_Yahoo_Search::factory('web');
$yahoo->setAppId('YAHOO_ID');
$yahoo->setSites(array('www.php.net'));
$yahoo->setQuery('mysql');

$results = $yahoo->submit();

foreach ($results as $result)
{
	echo $result['Title'] . '<br />';
}


 Comments   
Comment by Simone Carletti [ 28/Dec/07 05:23 PM ]
I investigated the issue.
Here's a few notes:

This is the URI queried by Zend_Service_Yahoo
http://search.yahooapis.com/WebSearchService/V1/webSearch?type=all&start=1&language=en&license=any&results=10&format=any&site=www.php.net&appid=API_KEY&query=mysql

I tried to remove each default parameter and I discovered license parameter can cause some problem when site is not empty, even if any is the default value.
I would suggest to remove the default value and left the parameter empty.

Comment by Kevin Golding [ 11/Jan/08 12:40 PM ]
Interesting this query has the "any" license set but returns 511 results:

http://search.yahooapis.com/WebSearchService/V1/webSearch?type=all&start=1&language=en&license=any&results=10&format=any&site=www.flickr.com&appid=API_KEY&query=mysql

All that changed is the site searched against. It seems Yahoo aren't consistent in their handling of the matter.

Comment by Wil Sinclair [ 21/Mar/08 05:05 PM ]
This issue should have been fixed for the 1.5 release.
Comment by Jonathan Maron [ 11/Apr/08 02:28 AM ]
It seems that in Zend Framework 1.5.1, the problem is still not solved.

The following code does not return any results:

// Zend Framework 1.5.1

include_once 'Zend/Service/Yahoo.php';

$yahoo = new Zend_Service_Yahoo('YAHOO_ID');

$results = $yahoo->webSearch('mysql', array('site' => 'www.php.net'));

foreach ($results as $result)
{
    echo $result->Title . '<br />';
}

echo "<hr />";

Removing the ", array('site' => 'www.php.net')" part of "webSearch" and executing again, returns results.

I personally think that Zend_Service_Yahoo::webSearch, with the 'site' option is a great way to implement a "site search" feature on anyway.

Comment by Kevin Golding [ 11/Apr/08 03:33 AM ]
All the testing I've done suggests there's an inconsistency at Yahoo's end. I think "fixing" it in ZF will be more a case of adding workarounds and exceptions to wrangle the results when we hit bad resultsets like mysql on php.net.
Comment by Wil Sinclair [ 18/Apr/08 01:11 PM ]
This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.
Comment by Simone Carletti [ 13/May/08 03:30 PM ]
@ Jonathan Maron
AFAIK nothing has been done to fix the issue for ZF 1.5 thus it's normal the issue still appears.

If I have a few minutes in the next days I'll give it a look.
Needless to say, patches are always welcomed from everyone.

Comment by Wil Sinclair [ 02/Jun/08 06:29 AM ]
Simone, could you please look at this and fix the bug or close the issue? Time to get some closure.

Thanks!
,Wil

Comment by Simone Carletti [ 04/Jun/08 03:52 AM ]
Hi Wil,
I'll try to give it a look.
Comment by Milan Momcilovic [ 21/Jun/08 11:17 AM ]
Hi all,

The license parameter causes problems. I tested the Yahoo web search service from my browser using the following URI:

http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YAHOO_API_KEY&query=Godfather&results=2&license=any

IMO, this should return the results from IMDB but it returns only results from Digg, which the license option ('license=any') does not work correctly.

When license parameter is not used at all, the correct results are returned - try this:

http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YAHOO_API_KEY&query=Godfather&results=2

Therefore, I think that the "license" option should be removed from $defaultOptions for now, until Yahoo guys fix this problem.

Thanks,
Milan

Comment by Sergei Izvorean [ 13/May/09 07:21 PM ]
This is still an issue in ZF 1.8.0. However the problem seems to be with Yahoo as it doesn't return any results if "license" parameter is present in REST query string. Once the parameter is removed everything works fine. I've done couple test using just a browser and modifying the query string.

Just need an option not to include "license" parameter in Zend_Yahoo_Service. Currently it is validated and cannot be omitted.

Thanks, Sergei

Generated at Sat Jul 04 13:57:34 PDT 2009 using JIRA Enterprise Edition, Version: 3.12.2-#300.