YQL, Flickr, OAuth, YAP

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    4 Favorites

    YQL, Flickr, OAuth, YAP - Presentation Transcript

    1. YQL, Flickr, OAuth, YAP Erik Eldridge Yahoo! Developer Network 3/31/09 Photo credit: Marco Bellucci((http://ow.ly/1M0c)
    2. Follow along (or skip ahead)
      • http://slideshare.net/erikeldridge
    3. YQL
    4. YQL is select * from internet
      • Allows you to quickly & simply mashup data from Yahoo! and elsewhere
      • Programmatic SQL-like language
      • Successor to Yahoo! Pipes
    5. YQL on YDN
    6. YQL console
    7. BOSS-like search
    8. Public data
    9. YQL proxy & frontend
    10. YQL trogdor
    11. HTML to extract
    12. HTML extraction in console
    13. HTML extraction code
    14. RSS extraction
    15. RSS raw
    16. RSS extraction in console
    17. RSS extraction code
    18. RSS extracted
    19. YQL Open Tables
    20. Open table examples
    21. Twitter status Open Table
    22. Twitter status table raw
    23. Twitter status Open Table in action
    24. Resources
      • YQL: http://developer.yahoo.com/yql
      • Open Table examples: http://github.com/spullara/yql-tables/tree/master
      • PHP: http://php.net
    25. Flickr
    26. Flickr homepage
    27. Flickr API page
    28. Use YQL for public pics
    29. Desc flickr.photos.search
    30. Resolve Flickr username
    31. Request user’s photos in YQL
    32. Use proxy to get data
    33. Catch the data in the client
    34. Output
    35. Flickr API endpoint
    36. Flickr API explorer
    37. Flickr Auth: fetching frob
    38. Flickr auth: fetching token
    39. Flickr auth: making request
    40. Resources
      • Flickr APIs: http://www.flickr.com/services/api/
    41. OAuth
    42. Overview
      • What is OAuth?
      • In general, how do I use it?
      • Getting started with Oauth on Yahoo!
    43. OAuth is an open protocol
      • Allows developers to safely access a user’s private data
      • Similar to OpenID
      • Used to secure HTTP requests
      • Credentials given only to trusted sites
      • Open alternative to proprietary protocols
        • Google’s AuthSub
        • AOL’s OpenAuth
        • Yahoo’s BBAuth and FlickrAuth
        • Facebook’s FacebookAuth
    44. How does a developer use it?
      • Fetch a request token
      • Redirect user to authorize with request token
      • Fetch and store an access token
      • Make signed API requests
    45. For the visually-inclined Your App (the consumer) API (Oauth provider) Your App API Access token Your App API Signed request The user API Authorization Your App API Request token Fetch request token
    46. Yahoo! Oauth diagram
      • http://ow.ly/1KuX
    47. How to get a Yahoo! Oauth API key and secret
    48. The YDN registration form
      • be sure to:
        • Select “Web-based” from the drop-down if you want to make a web app
        • Request access to “private user data” if you need social data in your app
    49. Successful registration
      • Shows the key and secret used for signing a request
    50. Domain verification
      • For web-based apps, you will need to verify that you own the domain that will be hosting your app
    51. The easiest way to get started is with the Yahoo! PHP SDK
      • <?php
      • require('yosdk/lib/Yahoo.inc');
      • $key = 'dj0yJmk9b25tMTdCb3NndVc3JmQ9WVdrOWRFRlFXbFJqTkRnbWNHbzlNakV6TmpNMU16TTUmcz1jb25zdW1lcnNlY3JldCZ4PWQ4';
      • $secret = 'ccb100d2ddd70c90e999055311b714db17a35029';
      • $app_id = 'tAPZTc48';
      • $session = YahooSession::requireSession($key, $secret, $app_id);
      • $user = $session->getSessionedUser();
      • $title = ' installed this OAuth app';
      • $link = 'http://example.erikeldridge.com/oauth/';
      • $suid = 'update'.time();
      • $user->insertUpdate($suid, $title, $link);
    52. An example update on the Yahoo! profile page
    53. App Updates
      • Updates are distributed across Yahoo! and beyond
      • Properties, e.g., Mail, Profiles, Buzz, etc.
      • Clients, e.g., Messenger, Toolbar
      • Externally through Updates API
    54.  
    55. The next easiest way is to use one of the freely available libraries
    56. Fetching request token without the Yahoo! PHP SDK
      • <?php
      • $key = 'dj0yJmk9b25tMTdCb3NndVc3JmQ9WVdrOWRFRlFXbFJqTkRnbWNHbzlNakV6TmpNMU16TTUmcz1jb25zdW1lcnNlY3JldCZ4PWQ4';
      • $secret = 'ccb100d2ddd70c90e999055311b714db17a35029';
      • require('yosdk/lib/OAuth.php');
      • $consumer = new OAuthConsumer($key, $secret);//key/secret from Y!
      • $url = 'https://api.login.yahoo.com/oauth/v2/get_request_token';
      • $request = OAuthRequest::from_consumer_and_token($consumer, NULL, 'POST', $url, array());
      • $request->sign_request(new OAuthSignatureMethod_PLAINTEXT(), $consumer, NULL);
      • $ch = curl_init($url);
      • $options = array(
      • CURLOPT_POSTFIELDS => $request->to_postdata(),
      • CURLOPT_RETURNTRANSFER => true
      • );
      • curl_setopt_array($ch, $options);
      • parse_str(curl_exec($ch), $resp);
      • curl_close($ch);
      • $requestToken = new stdclass();
      • $requestToken->key = $resp[&quot;oauth_token&quot;];
      • $requestToken->secret = $resp[&quot;oauth_token_secret&quot;];
      • file_put_contents('token.txt', json_encode($requestToken));
      • $url = sprintf(&quot;https://%s/oauth/v2/request_auth?oauth_token=%s&quot;,
      • 'api.login.yahoo.com',
      • urlencode($requestToken->key)
      • );
      • echo “go here & authorize: $url”;
    57. Fetching the access token without the Yahoo! PHP SDK, part 1
      • $key = 'dj0yJmk9b25tMTdCb3NndVc3JmQ9WVdrOWRFRlFXbFJqTkRnbWNHbzlNakV6TmpNMU16TTUmcz1jb25zdW1lcnNlY3JldCZ4PWQ4';
      • $secret = 'ccb100d2ddd70c90e999055311b714db17a35029';
      • $app_id = 'tAPZTc48';
      • require('yosdk/OAuth.php');
      • $consumer = new OAuthConsumer(KEY, SECRET);
      • $requestToken = json_decode(file_get_contents('token.txt'));
      • $url = 'https://api.login.yahoo.com/oauth/v2/get_token';
      • $request = OAuthRequest::from_consumer_and_token($consumer, $requestToken, 'POST', $url, array());
      • $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, $requestToken);
      • $headers = array(
      • &quot;Accept: application/json&quot;
      • );
      • $ch = curl_init($url);
      • $options = array(
      • CURLOPT_POST=> true,
      • CURLOPT_POSTFIELDS => $request->to_postdata(),
      • CURLOPT_RETURNTRANSFER => true
      • );
      • curl_setopt_array($ch, $options);
      • parse_str(curl_exec($ch), $response);
      • curl_close($ch);
    58. Fetching the access token without the Yahoo! PHP SDK, part 2
      • $now = time();
      • $accessToken = new stdclass();
      • $accessToken->key = $response[&quot;oauth_token&quot;];
      • $accessToken->secret = $response[&quot;oauth_token_secret&quot;];
      • $accessToken->guid = $response[&quot;xoauth_yahoo_guid&quot;];
      • $accessToken->consumer = $consumer;
      • $accessToken->sessionHandle = $response[&quot;oauth_session_handle&quot;];
      • if(array_key_exists(&quot;oauth_expires_in&quot;, $response)) {
      • $accessToken->tokenExpires = $now + $response[&quot;oauth_expires_in&quot;];
      • }else {
      • $accessToken->tokenExpires = -1;
      • }
      • if(array_key_exists(&quot;oauth_authorization_expires_in&quot;, $response)) {
      • $accessToken->handleExpires = $now + $response[&quot;oauth_authorization_expires_in&quot;];
      • }else {
      • $accessToken->handleExpires = -1;
      • }
      • file_put_contents('token.txt', json_encode($accessToken));
    59. Making a signed request to Updates API without the Yahoo! PHP SDK, part 1
      • $guid = $response[&quot;xoauth_yahoo_guid&quot;];
      • $title = 'Confirmation update';//arbitrary title
      • $description = 'The time is now '.date(&quot;g:i a&quot;);//arbitrary desc
      • $link = sprintf('http://%s/oauth/', ‘example.erikeldridge.com/oauth’);//arbitrary link
      • $source = ’APP.'.$app_id;//note: 'APP.' syntax
      • $date = time();
      • $suid = ’update'.time();//arbitrary, unique string
      • $body = array(
      • &quot;updates&quot; => array(
      • array(
      • &quot;collectionID&quot; => $guid,
      • &quot;collectionType&quot; => &quot;guid&quot;,
      • &quot;class&quot; => &quot;app&quot;,
      • &quot;source&quot; => $source,
      • &quot;type&quot; => 'appActivity',
      • &quot;suid&quot; => $suid,
      • &quot;title&quot; => $title,
      • &quot;description&quot; => $description,
      • &quot;link&quot; => $link,
      • &quot;pubDate&quot; => (string)$date
      • )
      • )
      • );
    60. Making a signed request to Updates API without the Yahoo! PHP SDK, part 2
      • $url = sprintf(&quot;http://%s/v1/user/%s/updates/%s/%s&quot;,
      • 'social.yahooapis.com',
      • $guid,
      • $source,
      • urlencode($suid)
      • );
      • $request = OAuthRequest::from_consumer_and_token(
      • $consumer,
      • $accessToken,
      • 'PUT',
      • $url,
      • array());
      • $request->sign_request(
      • new OAuthSignatureMethod_HMAC_SHA1(),
      • $consumer,
      • $accessToken
      • );
    61. Making a signed request to the Updates API without the Yahoo! PHP SDK, part 3
      • $headers = array(&quot;Accept: application/json&quot;);
      • $headers[] = $request->to_header();
      • $headers[] = &quot;Content-type: application/json&quot;;
      • $content = json_encode($body);
      • $ch = curl_init($url);
      • $options = array(
      • CURLOPT_HTTPHEADER => $headers,
      • CURLOPT_POSTFIELDS => $content,
      • CURLOPT_RETURNTRANSFER => true,
      • CURLOPT_CUSTOMREQUEST => 'PUT',
      • CURLOPT_TIMEOUT => 3
      • );
      • curl_setopt_array($ch, $options);
      • $resp = curl_exec($ch);
      • curl_close($ch);
    62. Resources
      • Hueniverse’s introduction: http://www.hueniverse.com/hueniverse/2007/10/beginners-guide.html
      • Yahoo!’s Oauth documentation: http://developer.yahoo.com/oauth
      • Yahoo! PHP and ActionScript SDKs: http://developer.yahoo.com/social/sdk/
      • Google’s OAuth playground: http://googlecodesamples.com/oauth_playground/
    63. Yahoo! Application Platform
    64. Why is Yahoo! opening up?
      • A history of supporting open technology
        • Apache, MySQL, PHP, JavaScript, BSD/Linux, to name a few
      • A history of hacking
      • Yahoo! wants to share its audience
    65. What is the Yahoo! Application Platform?
      • It’s a way to run apps on Yahoo!
    66. 3 views of YAP: My Y! screenshot
    67. 3 views of YAP: canvas screenshot
    68. 3 views of YAP: y! metro
    69. Yahoo! Application Platform (YAP)
      • Optimized for speed and security (YML, Caja)
      • Uses raw Javascript, CSS, and HTML, and Yahoo! Markup Language (YML)
      • Supports OpenSocial JavaScript API
    70. How do I use it?
      • YDN key/secret
      • +
      • Your server
      • +
      • Your code
      • =
      • Your app on Yahoo!
    71. Example: OpenSocial Activities
      • <script>
      • var params = {};
      • params[opensocial.Activity.Field.TITLE] = 'title';
      • params[opensocial.Activity.Field.BODY] = 'body';
      • var activity = opensocial.newActivity(params);
      • opensocial.requestCreateActivity(
      • activity,
      • opensocial.CreateActivityPriority.LOW,
      • function(){});
      • </script>
    72. Example: Screenshot of results
    73. What does YAP do for me?
      • Hundreds of millions of Yahoo! users
      • Instant publication
      • Secure, Standard JavaScript, HTML, CSS
      • OpenSocial JS API
    74. Resources
      • developer.yahoo.com
        • /dashboard
        • /yap
        • /yap/yml
        • /social
        • /forums
      • Caja project
      • iframe security
    75. ! תודה Thank you!
      • Find me on slideshare, twitter and github @erikeldridge
    SlideShare Zeitgeist 2009

    + Erik EldridgeErik Eldridge Nominate

    custom

    1588 views, 4 favs, 1 embeds more stats

    A presentation for IDC - 3/31/09 - Israel

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1588
      • 1582 on SlideShare
      • 6 from embeds
    • Comments 0
    • Favorites 4
    • Downloads 23
    Most viewed embeds
    • 6 views on http://javadialog.blogspot.com

    more

    All embeds
    • 6 views on http://javadialog.blogspot.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories