"); print ("Error: Cannot get two_legged_app (YahooApplication object)."); exit; } // Define queries for Flickr and an RSS news feed $flickr_query = "select * from flickr.photos.search where text=\"panda\" limit 3"; $news_feed = "select * from rss where url='http://rss.news.yahoo.com/rss/topstories' and title LIKE \"%China%\""; // Call the query and dump the response. echo "

Flickr Data

"; $flickrResponse = $two_legged_app->query($flickr_query); echo "
";
var_dump($flickrResponse);
echo "
"; echo "

RSS Data

"; $newsResponse = $two_legged_app->query($news_feed); echo "
";
var_dump($newsResponse);
echo "
"; if (($flickrResponse==NULL) OR ($newsResponse==NULL)) { print ("

"); print ("Warning: flickrResponse or newsResponse is NULL."); print ("Check your API Key (Consumer Key) and Shared Secret (Consumer Secret)"); print (" Also, make sure your query is valid."); print ("

"); } // The YahooSession class is used for three-legged authorization, // which does require permission from the end user. $session=YahooSession::requireSession(API_KEY, SHARED_SECRET); if ($session == NULL) { // Print error message and and then exit the script. print ("

"); print ("Error: Cannot get session object."); print (" Check your API Key (Consumer Key) and Shared Secret (Consumer Secret)"); print ("

"); exit; } // Define YQL queries for the Social Directory APIs $profile = "select * from social.profile where guid=me"; $contacts = "select fields.value from social.contacts where guid=me"; $connections = "select * from social.connections where owner_guid=me"; $updates = "select * from social.updates where guid=me"; $status = "select value.status from social.presence where guid=me"; $api_queries = array("Profiles"=>$profile, "Contacts"=>$contacts, "Connections"=>$connections, "Updates"=>$updates, "Presence"=>$status); // Make the calls to YQL and dump the responses. foreach($api_queries as $api=>$query) { echo "

$api Data

"; $queryResponse = $session->query($query); if ($queryResponse == NULL) { echo "

"; echo "Error: No query response for $api."; echo " Check your permissions. Also, check the syntax of the YQL query."; echo "

"; } else { echo "
";
      var_dump($queryResponse);
      echo "
"; } } ?>