Proxy Script To Yahoo API Term Extraction

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.

<p>Finally, here it is after a busy week.<p />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.<p />This works in Internet Explorer (IE6, IE7) and firefox, and is used in my <a href="http://www.kinlan.co.uk/AjaxExperiments/AjaxTag">AJAX </a>example.<p />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.<p />And thats it really.<p />Do you have any Questions, email me: <a href="mailto:paul.kinlan@gmail.com">Paul Kinlan</a> [paul.kinlan@gmail.com]<p /><span style="color: #33ff33;">#!/usr/bin/perl</span><span style="color: #6666cc;">use</span> LWP;<span style="color: #6666cc;">use</span> CGI qw(:standard);$CGI::POST_MAX=1024 * 100; # max 100K posts<span style="color: #cc66cc;">my</span>($qCGI) = new CGI();<span style="color: #cc66cc;">my</span>($YahooAppID) = "APPIDHERE";<p /><span style="color: #cc66cc;">my</span>($baseUrl) = "<a href="http://api.search.yahoo.com/"><a href="http://api.search.yahoo.com/">http://api.search.yahoo.com/</a></a>ContentAnalysisService/V1/termExtraction";<p /><span style="color: #cc66cc;">my</span>($context)= $qCGI->param('context');<span style="color: #cc66cc;">my</span>($query) = $qCGI->param('query');<span style="color: #cc66cc;">my</span>($finalUrl) = $baseUrl ;<p />$ua = LWP::UserAgent->new;$ua->agent("YahooPassThrough/0.1 ");<p /># Create a request<span style="color: #cc66cc;">my</span> $req = HTTP::Request->new(POST => $finalUrl);$req->content("appid=".$YahooAppID."&context=".$context."&query".$query);$req->content_type('application/x-www-form-urlencoded');<p /># Pass request to the user agent and get a response back<span style="color: #cc33cc;">my</span> $res = $ua->request($req);<span style="color: #6666cc;">print</span> "Content-type: text/xml\n\n";<span style="color: #6666cc;">print</span> $res->content;<p /></p>


Print Share Comment Cite Upload Translate
APA
Paul Kinlan | Sciencx (2024-03-29T05:47:30+00:00) » Proxy Script To Yahoo API Term Extraction. Retrieved from https://www.scien.cx/2005/08/27/proxy-script-to-yahoo-api-term-extraction/.
MLA
" » Proxy Script To Yahoo API Term Extraction." Paul Kinlan | Sciencx - Saturday August 27, 2005, https://www.scien.cx/2005/08/27/proxy-script-to-yahoo-api-term-extraction/
HARVARD
Paul Kinlan | Sciencx Saturday August 27, 2005 » Proxy Script To Yahoo API Term Extraction., viewed 2024-03-29T05:47:30+00:00,<https://www.scien.cx/2005/08/27/proxy-script-to-yahoo-api-term-extraction/>
VANCOUVER
Paul Kinlan | Sciencx - » Proxy Script To Yahoo API Term Extraction. [Internet]. [Accessed 2024-03-29T05:47:30+00:00]. Available from: https://www.scien.cx/2005/08/27/proxy-script-to-yahoo-api-term-extraction/
CHICAGO
" » Proxy Script To Yahoo API Term Extraction." Paul Kinlan | Sciencx - Accessed 2024-03-29T05:47:30+00:00. https://www.scien.cx/2005/08/27/proxy-script-to-yahoo-api-term-extraction/
IEEE
" » Proxy Script To Yahoo API Term Extraction." Paul Kinlan | Sciencx [Online]. Available: https://www.scien.cx/2005/08/27/proxy-script-to-yahoo-api-term-extraction/. [Accessed: 2024-03-29T05:47:30+00:00]
rf:citation
» Proxy Script To Yahoo API Term Extraction | Paul Kinlan | Sciencx | https://www.scien.cx/2005/08/27/proxy-script-to-yahoo-api-term-extraction/ | 2024-03-29T05:47:30+00:00
https://github.com/addpipe/simple-recorderjs-demo