0

I want to be notified if certain terms show up in Yahoo's top 10 "trending topics" list on their front page. I created a little script that parses out the front page using file_get_contents('http://www.yahoo.com'); and then uses regex to parse it out. This works, but it's brittle. What if they change the html around a little bit?

I'd like to do this the right way and get this same information as XML. SO I looked into using YQL. I've found the right query:

http://query.yahooapis.com/v1/yql?q=select%20*%20from%20timesense.trending%20where%20locale%3D'en-US'&diagnostics=true

But I don't quite understand how to use this to make my request because I get an Oauth error.

$request = "http://query.yahooapis.com/v1/yql?q=select%20*%20from%20timesense.trending%20where%20locale%3D'en-US'&diagnostics=true"; 
$session = curl_init($request);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$list = curl_exec($session);
echo $list;

gives me this error:

Please provide valid credentials. OAuth oauth_problem="OST_OAUTH_PARAMETER_ABSENT_ERROR", realm="yahooapis.com"Please provide valid credentials. OAuth oauth_problem="OST_OAUTH_PARAMETER_ABSENT_ERROR", realm="yahooapis.com"

Now I know I need to create an access key/API key. I have one now. I just don't know how to include it. All the examples I see are either for social apps where I'd be requesting a user's login/password. All I want is to use PHP to get this one list of 10 things as XML. What can I do to get this? What should my next step be?

George Brighton
  • 5,131
  • 9
  • 27
  • 36
pg.
  • 2,503
  • 4
  • 42
  • 67

1 Answers1

0

Some of the YQL tables require "two legged" OAuth, basically meaning a signature on the request. My comments on this answer should help explain the signature steps needed: How do I get started with oauth for YQL for historical stock data?

Community
  • 1
  • 1
BrianC
  • 10,591
  • 2
  • 30
  • 50