Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // This is a simple code example, which illustrates how easy it is to not only get any YQL data rendered on a web page, but also how to call the Updates Firehose YQL Table. Follow the comments for additional help.
- // Your config file, which contains $CONSUMER_KEY & $CONSUMER_SECRET info
- require_once('config.php');
- // grab the following library here: http://github.com/yahoo/yos-social-php5
- require_once('lib/OAuth/OAuth.php');
- require_once('lib/Yahoo/YahooOAuthApplication.class.php');
- // instantiate a new oauth application, reference your credentials in config.php
- $oauthapp = new YahooOAuthApplication($CONSUMER_KEY, $CONSUMER_SECRET, '');
- // very easily state your yql statement as a string
- $rsp = $oauthapp->yql('select * from social.updates.search where query="X-Men";');
- // create var updates
- $updates = $rsp->query->results->update;
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
- <html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta http-equiv="refresh" content="4;url=updatesfirehose.php">
- <title>YQL Updates Firehose Demo (YOS SDK)</title>
- <style type='text/css'>
- /* A little lazy CSS3 magic. Sure, why not? Sadly, only works in webkit/safari, but you can do all this in FireFox too */
- body{font-family:verdana;font-size:11px;background:-webkit-gradient(linear, left top, left bottom, from(#000), to(#ccc), to(#000));background-color:#3D3D3D;}
- h1{/*text-shadow: 0.1em 0.1em 0.2em #C0C0C0;*/color:#fff;}
- #container{text-align:center;margin-left:auto;margin-right:auto;height:100%;}
- a{font-size:120%;font-weight:bold;color:#3154C7;}
- #results{text-align:left; width: 60%; margin-left: 15%; border: 1px solid #8D8D8D; padding: 20px; height: 600px; overflow: auto; background:#fff; }
- .updateitem{border:1px solid #C8C8C8;padding:20px;-moz-border-radius: 5px; -webkit-border-radius: 5px;background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#fff), color-stop(0.1, #E5E5E5), color-stop(0.5, #F2F2F2));}
- .sourcemini{float:right;}
- </style>
- </head>
- <body>
- <div id="container">
- <div id="heading"><h1>Yahoo! YQL Updates Firehose Demo</h1></div>
- <div id="results">
- <?php
- // Here's where the updates get built out - each item is pulled out of the array and set as a var.
- foreach($updates as $update) {
- $link = $update->link;
- $title = $update->title;
- $source = $update->source;
- // And render the thing.
- echo <<<HTML
- <p class='updateitem'><a href="{$link}">{$title}</a>
- <br><span class='sourcemini'>{$source}</span></p>
- HTML;
- }
- ?>
- </div></div>
- </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement