Good day bros. I am trying to use LWP to access Yahoo's content analysis API. The code I am using follows:
my $text = qq("Researchers from the University of Minnesota's Institut +e on the Environment looked at 17 key crops that produce 86 percent o +f the world crop calories.); my $ua = LWP::UserAgent->new(); my $response = $ua->post( 'http://query.yahooapis.com/v1/public/yql', ['q' => "select * from contentanalysis.analyze where text='".$text +."'"] ); print $response->content();
When I run this I get:
<?xml version="1.0" encoding="UTF-8"?> <error xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:lang=" +en-US"><description>Query syntax error(s) [line 1:96 missing EOF at ' +s']</description></error>
So it doesn't like the apostrophe in the query. When I take out the apostrophe, it works like it's supposed to. Since it's a SQL-like query, I tried using double apostrophes, like you would to escape a query string in SQL, and that produced the same error. So I tried URI::Escape on the string. That yields response status of OK, but no contents in the results, i.e.
<?xml version="1.0" encoding="UTF-8"?> <query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count= +"0" yahoo:created="2014-07-19T19:41:26Z" yahoo:lang="en-US"><results/ +></query><!-- total: 177 --> <!-- engine4.yql.ne1.yahoo.com -->
Anyone know how I can get this working?

In reply to How to transmit text to Yahoo Content Analysis by cormanaz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.