0

Need help with YQL on php

Hi,
I was able to successfully use this code on Yahoo search extraction api which Yahoo is closing on 31st and now I am trying to use YQL and ended with the following error -

CODE
Syntax error(s) [line 0:-1 expecting statement_ql at '<EOF>']


my code -

CODE
function sendToHost($host,$method,$path,$data,$useragent=0)
{
// Supply a default method of GET if the one passed was empty
if (empty($method)) {
$method = 'GET';
}
$method = strtoupper($method);
$fp = fsockopen($host, 80);
if ($method == 'GET') {
$path .= '?' . $data;
}
fputs($fp, $method." ".$path." HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
if ($useragent) {
fputs($fp, "User-Agent: MSIE\r\n");
}
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST') {
fputs($fp, $data);
}

while (!feof($fp)) {
$buf .= fgets($fp,128);
}
fclose($fp);
return $buf;
}

$content = "Obama likely to base re-election campaign in Chicago";

$content="select * from search.termextract where context='".urlencode(utf8_decode(strip_tags($content)));

$data=sendToHost('query.yahooapis.com','POST','/v1/public/yql?q=',$content);

echo $data;


Any idea how can I get my code to work with YQL?

by
0 Replies

Recent Posts

in YQL