Finally, here it is after a busy week.What follows is a listing of the code I created to create a proxy that would allow me to access the Yahoo API from any browser with out having to worry about Cross Site Scripting.This works in Internet Explorer (IE6, IE7) and firefox, and is used in my AJAX example.Bascially, it retrieves a POST request from the browser and forwards the result inside another POST request to Yahoo, once I recieve the response, I pass back the XML to the web browser.And thats it really.Do you have any Questions, email me: Paul Kinlan [email@example.com]#!/usr/bin/perluse LWP;use CGI qw(:standard);$CGI::POST_MAX=1024 * 100; # max 100K postsmy($qCGI) = new CGI();my($YahooAppID) = "APPIDHERE";my($baseUrl) = "http://api.search.yahoo.com/ContentAnalysisService/V1/termExtraction";my($context)= $qCGI->param('context');my($query) = $qCGI->param('query');my($finalUrl) = $baseUrl ;$ua = LWP::UserAgent->new;$ua->agent("YahooPassThrough/0.1 ");# Create a requestmy $req = HTTP::Request->new(POST => $finalUrl);$req->content("appid=".$YahooAppID."&context=".$context."&query".$query);$req->content_type('application/x-www-form-urlencoded');# Pass request to the user agent and get a response backmy $res = $ua->request($req);print "Content-type: text/xml\n\n";print $res->content;
About Me: Paul Kinlan
I lead the Chrome Developer Relations team at Google.
We want people to have the best experience possible on the web without having to install a native app or produce content in a walled garden.
Our team tries to make it easier for developers to build on the web by supporting every Chrome release, creating great content to support developers on web.dev, contributing to MDN, helping to improve browser compatibility, and some of the best developer tools like Lighthouse, Workbox, Squoosh to name just a few.