Why do I get this error?
Syntax error(s) [line 3:63 missing EOF at ‘select’]
Code:
$twitterUrl ="https://query.yahooapis.com/v1/public/yql?q=";
$twitterUrl .= urlencode("select * from twitter.oauth.accesstoken where oauth_verifier=@verifier
and oauth_consumer_key=@consumer_key and oauth_consumer_secret=@consumer_secret
and oauth_token=@token and oauth_token_secret=@token_secret;");
$twitterUrl .= urlencode("select * from twitter.status.timeline.user where id='jzm'");
$twitterUrl .="&format=json";
$twitterUrl .="&env=http://datatables.org/alltables.env";
$twitterFeed = file_get_contents($twitterUrl, true);
$twitterFeed = json_decode($twitterFeed);
Your query is putting 2 select statements together, separated by a semicolon, something like:
YQL only allow ones select statement, so it’s complaining about the second one. (It’s different in this regard from something like MySQL.)
You could re-order your parameters, making it one (valid) select statement like the following:
Note that you'll still need to get the
oauth_tokenandoauth_token_secretfrom the OAuth flow with Twitter. The advantage of YQL here is that it can do the request signing for you, avoiding the need for a 3rd-party OAuth or Twitter/OAuth library.