open hack nyc yahoo social sdks

60
Jon LeBlanc + Dustin Whittle Yahoo! Developer Network Yahoo Social SDKs

Upload: dustin-whittle

Post on 06-May-2015

2.458 views

Category:

Technology


2 download

DESCRIPTION

Open Hack NYC Yahoo Social SDKs

TRANSCRIPT

Page 1: Open Hack NYC Yahoo Social SDKs

Jon LeBlanc + Dustin Whittle

Yahoo! Developer Network

Yahoo Social SDKs

Page 2: Open Hack NYC Yahoo Social SDKs

DEVELOPER.YAHOO.COMEXAMPLES | TUTORIALS | CODE SAMPLES

Page 3: Open Hack NYC Yahoo Social SDKs
Page 4: Open Hack NYC Yahoo Social SDKs

Open applications are applications that run on the Yahoo! network: Yahoo! Homepage and My Yahoo!

OAuth applications are standalone applications the run off the Yahoo! network.

Page 5: Open Hack NYC Yahoo Social SDKs

SDK Prerequisites

• ck = CONSUMER_KEY• cks = CONSUMER_SECRET• app = APPLICATION_ID• cb = CALLBACK_URL

Page 6: Open Hack NYC Yahoo Social SDKs
Page 7: Open Hack NYC Yahoo Social SDKs
Page 8: Open Hack NYC Yahoo Social SDKs
Page 9: Open Hack NYC Yahoo Social SDKs
Page 10: Open Hack NYC Yahoo Social SDKs
Page 11: Open Hack NYC Yahoo Social SDKs

11

SDK Code Dive What can you do?

Page 12: Open Hack NYC Yahoo Social SDKs

Yahoo! Social Apps – A good foundation

Scalable Hosting– Joyent – Free OpenSocial Accelerators– Google App Engine– Amazon EC2 + S3

Web App Framework– PHP (symfony)– Python (Django)– Ruby (Rails)

Page 13: Open Hack NYC Yahoo Social SDKs
Page 14: Open Hack NYC Yahoo Social SDKs

What SDK Languages Are Available?

PHP, Python, Java, ActionScript 3,Objective-C, and OpenSocial

http://www.github.com/yahoo

Page 15: Open Hack NYC Yahoo Social SDKs

Yahoo! Social SDK – Features

• Examples for OpenSocial, PHP, Python• Authenticating with OAuth• Fetching Profiles• Fetching and Inserting Updates• Fetching Connections• Executing YQL

Page 16: Open Hack NYC Yahoo Social SDKs

What is OpenSocial?

• OpenSocial API• For developing applications on social networks

• Accessing social data (profiles, connections)• Fetching and inserting activities

• Implemented by many containers• Develop once, distribute broadly

Page 17: Open Hack NYC Yahoo Social SDKs
Page 18: Open Hack NYC Yahoo Social SDKs

Collecting User Data With OpenSocial 0.8

/* OpenSocial PERSON data request */

var req = opensocial.newDataRequest(); var params = {};params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [ opensocial.Person.Field.NAME, opensocial.Person.Field.THUMBNAIL_URL];

req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer_profile');req.send(response);

Page 19: Open Hack NYC Yahoo Social SDKs

Collecting User Data With OpenSocial 0.8

/* response handler */function response(data){ var viewer = data.get('viewer_profile').getData(); var aboutme = viewer.getField(opensocial.Person.Field.NAME);}

Page 20: Open Hack NYC Yahoo Social SDKs

PHP Example: OAuth Dance

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

$user = $session->getSessionedUser();

var_dump($user);

Page 21: Open Hack NYC Yahoo Social SDKs
Page 22: Open Hack NYC Yahoo Social SDKs
Page 23: Open Hack NYC Yahoo Social SDKs

PHP Example: Fetching Profile Data

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

$user = $session->getSessionedUser();

$profile = $user->getProfile();

var_dump($profile);

Page 24: Open Hack NYC Yahoo Social SDKs

Python Example: OAuth Dance

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

# fetch unauthorized request tokenrequest_token = oauthapp.get_request_token(callback)

# authorize request tokenauthorization_url = oauthapp.get_authorization_url(request_token)

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

oauthapp.token = access_token

Page 25: Open Hack NYC Yahoo Social SDKs

Python Example: Fetching Profile Data

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

print profile

Page 26: Open Hack NYC Yahoo Social SDKs

Yahoo! Updates

Page 27: Open Hack NYC Yahoo Social SDKs

Getting Updates With OpenSocial 0.8

var req = opensocial.newDataRequest();var spec = new opensocial.IdSpec();

spec.setField(opensocial.IdSpec.Field.USER_ID, opensocial.IdSpec.PersonId.OWNER);

req.add(req.newFetchActivitiesRequest(spec), 'ownerActivities');

req.send(handleActivities);

Page 28: Open Hack NYC Yahoo Social SDKs

Getting Updates With OpenSocial 0.8

function handleActivities(dataResponse) { var ownerActivities =

dataResponse.get('ownerActivities').getData();

//parse owner activities}

Page 29: Open Hack NYC Yahoo Social SDKs

PHP Example: Fetching Updates

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

$user = $session->getSessionedUser();

$updates = $user->getUpdates();

var_dump($updates);

Page 30: Open Hack NYC Yahoo Social SDKs

Python Example: Fetching Updates

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

print updates

Page 31: Open Hack NYC Yahoo Social SDKs

Inserting Updates with OpenSocial 0.8

var params = {}, activity;params[opensocial.Activity.Field.TITLE] = title;params[opensocial.Activity.Field.BODY] = body;activity = opensocial.newActivity(params);

opensocial.requestCreateActivity(activity,opensocial.CreateActivityPriority.LOW,callback);

Page 32: Open Hack NYC Yahoo Social SDKs

PHP Example: Inserting Updates

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

$user = $session->getSessionedUser();

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

var_dump($update);

Page 33: Open Hack NYC Yahoo Social SDKs

Python Example: Inserting Updates

oauthapp = yahoo.application.OAuthApplication(key, secret, app_id, callback)update = oauthapp.insertUpdate(title, description, link)

print update

Page 34: Open Hack NYC Yahoo Social SDKs

Fetching Connections With OpenSocial 0.8

/* get owner and owner friends */var idspec = opensocial.newIdSpec({ 'userId' :

'OWNER', 'groupId' : 'FRIENDS' });var req = opensocial.newDataRequest();req.add(req.newFetchPersonRequest('OWNER'),

'get_owner');req.add(req.newFetchPeopleRequest(idspec),

'get_friends');req.send(responseFriends);

Page 35: Open Hack NYC Yahoo Social SDKs

Fetching Connections With OpenSocial 0.8

/* connection response function */function responseFriends(data){ var owner = data.get('get_owner').getData(); var objFriends = data.get('get_friends').getData(); var html = 'Friends of ' + owner.getDisplayName() + '<br />'; objFriends.each(function(person) { html += person.getDisplayName() + '<br />'; }); }

Page 36: Open Hack NYC Yahoo Social SDKs

PHP Example: Fetching Connections

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

$user = $session->getSessionedUser();

$connections = $user->getConnections();

var_dump($connections);

Page 37: Open Hack NYC Yahoo Social SDKs

Python Example: Fetching Connections

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

print connections

Page 38: Open Hack NYC Yahoo Social SDKs
Page 39: Open Hack NYC Yahoo Social SDKs
Page 40: Open Hack NYC Yahoo Social SDKs

The Yahoo! Query Language (YQL)

SELECT myColumn, myTitle FROM myTableWHERE col = 'value' AND var = 'title‘LIMIT 3 OFFSET 10 |sort(field='myColumn') | reverse()

Page 41: Open Hack NYC Yahoo Social SDKs

Getting Social Data with YQL

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 42: Open Hack NYC Yahoo Social SDKs

Making AJAX Requests With OpenSocial 0.8

var params = {};var url = 'http://developer.yahoo.com/yql/console/?

q=select%20*%20from%20flickr.photos.search%20where%20text%3D%22Times%20Square%22'

var callback = callbackFunc;

params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;

params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;

gadgets.io.makeRequest(url, callback, params);

Page 43: Open Hack NYC Yahoo Social SDKs

Making AJAX Requests With OpenSocial 0.8

function callbackFunc(response){ if (response.text){ //use response.txt }}

Page 44: Open Hack NYC Yahoo Social SDKs

PHP Example: Executing YQL

$application = new YahooApplication($key, $secret);$results = $application->query(‘select * from delicious.feeds.popular’);

var_dump($results);

Page 45: Open Hack NYC Yahoo Social SDKs

Python Example: Executing YQL

oauthapp = yahoo.application.OAuthApplication(key, secret, app_id, callback)results = oauthapp.yql('select * from social.profile where guid=me')

print results

Page 46: Open Hack NYC Yahoo Social SDKs

Getting Started - Documentation

Y!OS Main Overview - http://developer.yahoo.com/yosYAP Main Overview - http://developer.yahoo.com/yapYQL Docs - http://developer.yahoo.com/yqlYML Docs - http://developer.yahoo.com/yap/yml YDN Forum – http://developer.yahoo.com/forumYAP Dashboard - http://developer.yahoo.com/dashboardYQL Console - http://developer.yahoo.com/yql/console

Application Gallery - http://apps.yahoo.com/myappsJSLint - http://www.jslint.com

Github SDKs – http://www.github.com/yahoo (yos-social-LANGUAGE)PHP SDK - http://developer.yahoo.com/social/sdk/AS3 SDK - http://developer.yahoo.com/flash/yos/

Caja - http://code.google.com/p/google-caja/ Caja Guide - http://developer.yahoo.com/yap/guide/caja-support.html OpenSocial Spec - http://code.google.com/apis/opensocial

Page 47: Open Hack NYC Yahoo Social SDKs

Yahoo! Social SDKs: Live Demo

Joyent Accelerator + PHP SDK• http://apps.yahoo.com/-ZVumNI5a

Google App Engine + Python SDK• http://yapdemo.appspot.com/

Page 48: Open Hack NYC Yahoo Social SDKs
Page 49: Open Hack NYC Yahoo Social SDKs
Page 50: Open Hack NYC Yahoo Social SDKs
Page 51: Open Hack NYC Yahoo Social SDKs

QUESTIONS?

DEVELOPER.YAHOO.COMEXAMPLES | TUTORIALS | CODE SAMPLES

Page 52: Open Hack NYC Yahoo Social SDKs

DEVELOPER.YAHOO.COMEXAMPLES | TUTORIALS | CODE SAMPLES

ENJOY THE REST OFYAHOO! OPEN HACK DAY!

Page 53: Open Hack NYC Yahoo Social SDKs
Page 54: Open Hack NYC Yahoo Social SDKs
Page 55: Open Hack NYC Yahoo Social SDKs
Page 56: Open Hack NYC Yahoo Social SDKs
Page 57: Open Hack NYC Yahoo Social SDKs
Page 58: Open Hack NYC Yahoo Social SDKs
Page 59: Open Hack NYC Yahoo Social SDKs
Page 60: Open Hack NYC Yahoo Social SDKs