How mine is different
In the article above you need to use Google's SOAP service, so if you're not lucky enough to be running PHP5, you'll probably need something along the lines of PEAR SOAP or NuSOAP. That implies you also need a web server, running PHP. Then you need a Google API key and you need to download stuff and upload it to your server.
About the Yahoo! JSON web service
By the way, if you're wondering about the beauty of JSON, try this eye-opener.
Ah, yes, the demo is here.
Enter a/ your URL, or part of it, and b/ a search query. Then the script will tell you where in the first 1000 results is your URL to be found. If it is found.
How it works
Check the source for the details, it's reasonably well commented, but the big picture:
- You make a request (in
yjsonrank.makeRequest()) by appending a new SCRIPT element to the HEAD of your HTML. The URL of the script element (the SRC attribute) points to the Y! web service and also passes the search query and a function to be called once the script is included. This function happens to be
yjsonrank.process()function receives JSON data returned by the service, assigned to the
- We loop through
resp.ResultSet, checking every
Urlproperty contains our URL. If yes - we're done! If not, we make another request this time for the next 50 results. (50 is randomly chosen, feel free to modify). We continue until we reach 1000th result, which is the max that Y! will be willing to give.
And that's pretty much it, the rest is just fluff and beautifications
More Y! info
- The JSON description
- The Web Search API page, listing all the additional parameters you can add to your search request and what format would have the result