open hack day bangalore: hacking yahoo! social

71
Saurabh Sahni Developer, Hacker, Evangelist Hacking Yahoo! Social and Meme

Upload: saurabh-sahni

Post on 16-May-2015

4.422 views

Category:

Education


1 download

DESCRIPTION

Introduction to Yahoo! Social APIs

TRANSCRIPT

Page 1: Open Hack Day Bangalore: Hacking Yahoo! Social

Saurabh Sahni Developer, Hacker, Evangelist

Hacking Yahoo! Social and Meme

Page 2: Open Hack Day Bangalore: Hacking Yahoo! Social

User Data 

Updates 

Connec/ons 

Status 

h3p://pulse.yahoo.com/sahni_saurabh 

Page 3: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 4: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 5: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 6: Open Hack Day Bangalore: Hacking Yahoo! Social

YAHOO! MESSENGER 

Page 7: Open Hack Day Bangalore: Hacking Yahoo! Social

Y! Social APIs

h3p://developer.yahoo.com/social/ 

    SOCIAL     DIRECTORY  

 YAHOO!  CONTACTS 

STATUS 

MEME 

UPDATES 

Page 8: Open Hack Day Bangalore: Hacking Yahoo! Social

Leverage Yahoo!’s 600+ million users in your social

applications with Yahoo!’s Social APIs.

Page 9: Open Hack Day Bangalore: Hacking Yahoo! Social

 Open applica/ons are applica/ons that run on the Yahoo! network or other open social containers 

 OAuth applica/ons are standalone applica/ons that run off the Yahoo! network. 

Two ways to hack Social APIs

Page 10: Open Hack Day Bangalore: Hacking Yahoo! Social

Easiest way to use Social APIs is via

YQL

Page 11: Open Hack Day Bangalore: Hacking Yahoo! Social

h3p://developer.yahoo.com/yql/console/ 

h3p://developer.yahoo.com/yql/console/ 

Page 12: Open Hack Day Bangalore: Hacking Yahoo! Social

Fetching your profile data

select * from social.profile where guid=me;

Page 13: Open Hack Day Bangalore: Hacking Yahoo! Social

Profile Data 

Page 14: Open Hack Day Bangalore: Hacking Yahoo! Social

Finding your contacts

select * from social.contacts where guid=me;

Page 15: Open Hack Day Bangalore: Hacking Yahoo! Social

Contacts 

Page 16: Open Hack Day Bangalore: Hacking Yahoo! Social

Fetching any user’s profile data

select * from social.profile where guid=

‘7VABDKK365VEHCUDYFO6HUSKQM’;

Page 17: Open Hack Day Bangalore: Hacking Yahoo! Social

Fetching your updates

select * from social.updates where guid=me;

Page 18: Open Hack Day Bangalore: Hacking Yahoo! Social

Updates 

Page 19: Open Hack Day Bangalore: Hacking Yahoo! Social

Updates from your contacts

select * from social.contacts.updates where guid=me;

Page 20: Open Hack Day Bangalore: Hacking Yahoo! Social

Updates Firehose

Access all Yahoo! Updates in real time via YQL h3p://www.flickr.com/photos/thomashawk/250792779/ 

Page 21: Open Hack Day Bangalore: Hacking Yahoo! Social

Update Sources: 75+

http://developer.yahoo.com/social/rest_api_guide/updates-update_sources.html

Page 22: Open Hack Day Bangalore: Hacking Yahoo! Social

Updates Firehose 

Page 23: Open Hack Day Bangalore: Hacking Yahoo! Social

Finding updates about iPad

select * from social.updates.search where query=’iPad';

Page 24: Open Hack Day Bangalore: Hacking Yahoo! Social

Updates associated with huffingtonpost.com

select * from social.updates.search where link='huffingtonpost.com';

Page 25: Open Hack Day Bangalore: Hacking Yahoo! Social

Tweets in Yahoo! Updates

select * from social.updates.search where source = 'twitter';

Page 26: Open Hack Day Bangalore: Hacking Yahoo! Social

Updates from your application

select * from social.updates.search where source = '7BNRkt42';

Page 27: Open Hack Day Bangalore: Hacking Yahoo! Social

Yahoo! Meme: meme.yahoo.com 

Page 28: Open Hack Day Bangalore: Hacking Yahoo! Social

My Meme: h3p://meme.yahoo.com/saurabhsahni 

Page 29: Open Hack Day Bangalore: Hacking Yahoo! Social

Yahoo! Meme Dashabord: meme.yahoo.com 

Page 30: Open Hack Day Bangalore: Hacking Yahoo! Social

Meme API: http://developer.yahoo.com/meme/

Page 31: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 32: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 33: Open Hack Day Bangalore: Hacking Yahoo! Social

More with meme

•  INSERT INTO meme.user.posts (type, content, caption) VALUES ("photo", "http://www.yahoo.com/myphoto.jpg", "this is the photo caption”)

•  INSERT INTO meme.user.posts (type, content, caption) VALUES ("video", "http://www.vimeo.com/12345", "this video is awesome")

•  SELECT * FROM meme.search WHERE query=”hackday”

•  SELECT * FROM meme.popular WHERE locale='in'

Page 34: Open Hack Day Bangalore: Hacking Yahoo! Social

34 

Y! Social SDK  What can you do? 

h3p://www.flickr.com/photos/phploveme/2847931240/ 

Page 35: Open Hack Day Bangalore: Hacking Yahoo! Social

Yahoo! Social SDK – Features 

•  Examples for OpenSocial, PHP, Python

•  Performs OAuth authorizaiton

•  REST calls to the Yahoo! Social Web Services

–  Fetching Profiles

–  Fetching and Inserting Updates

–  Fetching Connections

–  Executing YQL

Page 36: Open Hack Day Bangalore: Hacking Yahoo! Social

SDK Languages hHp://developer.yahoo.com/social/sdk/ 

Page 37: Open Hack Day Bangalore: Hacking Yahoo! Social

Scalable Hosting

h3p://signup.joyent.com/yahoo_signup  

Page 38: Open Hack Day Bangalore: Hacking Yahoo! Social

Example Apps

Page 39: Open Hack Day Bangalore: Hacking Yahoo! Social

Flixter on Yahoo!

USER DATA 

DATA  

LOCATION 

    UPDATES   

CONTACTS 

AUTHENTICATION 

Page 40: Open Hack Day Bangalore: Hacking Yahoo! Social

Updatesville

Page 41: Open Hack Day Bangalore: Hacking Yahoo! Social

Updatesville

Page 42: Open Hack Day Bangalore: Hacking Yahoo! Social

Social Search

Social Search

Page 43: Open Hack Day Bangalore: Hacking Yahoo! Social

Social Search

Page 44: Open Hack Day Bangalore: Hacking Yahoo! Social

Slidememe

Page 45: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 46: Open Hack Day Bangalore: Hacking Yahoo! Social

Slidememe

Slidememe

Page 47: Open Hack Day Bangalore: Hacking Yahoo! Social

Hack: Updates in your language

h3p://www.flickr.com/photos/dimitridf/2841804136/ 

Page 48: Open Hack Day Bangalore: Hacking Yahoo! Social

DEMO

Page 49: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 50: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 51: Open Hack Day Bangalore: Hacking Yahoo! Social

h3ps://developer.apps.yahoo.com/projects/  

Page 52: Open Hack Day Bangalore: Hacking Yahoo! Social

h3ps://developer.apps.yahoo.com/projects/ 

Page 53: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 54: Open Hack Day Bangalore: Hacking Yahoo! Social

Gadget XML: h3p://github.com/saurabhsahni/Hacks  

Page 55: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 56: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 57: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 58: Open Hack Day Bangalore: Hacking Yahoo! Social

PHP Code: h3p://github.com/saurabhsahni/Hacks 

Page 59: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 60: Open Hack Day Bangalore: Hacking Yahoo! Social
Page 61: Open Hack Day Bangalore: Hacking Yahoo! Social

PHP Example: OAuth Dance 

$session = YahooSession::requireSession($key, $secret, $app_id)

$user = $session->getSessionedUser();

var_dump($user);

Page 62: Open Hack Day Bangalore: Hacking Yahoo! Social

Social Data with YQL ‐ Recap  

select * from social.profile where guid=me

select * from social.connections where owner_guid=me

select message from social.profile.status where guid=me

select * from social.updates where guid=me

Page 63: Open Hack Day Bangalore: Hacking Yahoo! Social

PHP Example: ExecuTng YQL 

$session = YahooSession::requireSession($key, $secret, $app_id)

$results = $session->query(‘select * from social.updates where guid=me’);

var_dump($results);

Page 64: Open Hack Day Bangalore: Hacking Yahoo! Social

PHP Example: InserTng Updates 

$session = YahooSession::requireSession ($key, $secret, $app_id)

$user = $session->getSessionedUser();

$update = $user->insertUpdate($suid, $title, $link, $description);

var_dump($update);

Page 65: Open Hack Day Bangalore: Hacking Yahoo! Social

GeUng Started ‐ DocumentaTon

•  Yahoo! Social APIs - http://developer.yahoo.com/social/

•  Meme APIs: http://developer.yahoo.com/meme/

•  Yahoo! Query Language - http://developer.yahoo.com/yql/

•  Yahoo! Social SDKs- http://developer.yahoo.com/social/sdk/

•  Examples - http://github.com/saurabhsahni/Hacks

Page 66: Open Hack Day Bangalore: Hacking Yahoo! Social

THANK YOU! 

Saurabh Sahni h3p://www.saurabhsahni.com  h3p://twi3er.com/saurabhsahni h3p://pulse.yahoo.com/sahni_saurabh  h3p://slideshare.net/saurabhsahni 

Page 67: Open Hack Day Bangalore: Hacking Yahoo! Social

Appendix

Page 68: Open Hack Day Bangalore: Hacking Yahoo! Social

What is OpenSocial? 

•  OpenSocial API •  For developing applicaTons on social networks •  Accessing social data (profiles, connecTons) •  Fetching and inserTng acTviTes 

•  Implemented by many containers •  Develop once, distribute broadly 

Page 69: Open Hack Day Bangalore: Hacking Yahoo! Social

Python Example: OAuth Dance 

oauthapp = yahoo.application.OAuthApplication (key, secret, app_id, callback)

# fetch unauthorized request token request_token = oauthapp.get_request_token(callback)

# authorize request token authorization_url = oauthapp.get_authorization_url(request_token)

# refresh authorized request token with access token access_token = oauthapp.get_access_token(request_token)

oauthapp.token = access_token

Page 70: Open Hack Day Bangalore: Hacking Yahoo! Social

Python Example: Fetching Profile Data

oauthapp = yahoo.application.OAuthApplication(key, secret, app_id, callback)

profile = oauthapp.getProfile()

print profile

Page 71: Open Hack Day Bangalore: Hacking Yahoo! Social

Python Example: ExecuTng YQL 

oauthapp = yahoo.application.OAuthApplication(key, secret, app_id, callback)

results = oauthapp.yql('select * from social.profile where guid=me')

print results