500 likes | 523 Vues
Yahoo! Application Platform (YAP) presentation for the South East Asia (SEA) Open Hack Day in Jakarta, Indonesia (November 2009)
E N D
Jonathan LeBlanc - Technology Evangelist Yahoo! Developer Network Twitter: @jcleblanc Y!OS and the Yahoo! Application Platform
Presentation Topics – What We’ll Cover (Part 1) • The Yahoo! Open Strategy (Y!OS) • The Yahoo! Application Platform (YAP) • What are Applications on YAP? • Creating YAP Applications • OAuth • OpenID • The Yahoo! Markup Language
Presentation Topics – What We’ll Cover (Part 2) • OpenSocial Support -Code Samples for using the SDK and OpenSocial • The YAP Social APIs • Frontend Security using Caja • Beta Support for the Yahoo! User Interface Library (YUI)
EXAMPLES | TUTORIALS | CODE SAMPLES DEVELOPER.YAHOO.COM
Creating Applications Create a Profile for Your Account http://profiles.yahoo.com Create an Application Using the Dashboard System http://developer.yahoo.com/dashboard Get Documentation and Resources http://developer.yahoo.com/yos
SDKs (Software Development Kits) PHP, Python, Java, ActionScript 3, Objective-C, and OpenSocial REST APIs http://www.github.com/yahoo
Using the Yahoo! Markup language (YML) YML Documentation http://developer.yahoo.com/yap/guide/yapdev-yml.html YML Samples http://developer.yahoo.com/yap/guide/yml-code-exs.html
Jonathan LeBlanc - Technology Evangelist Yahoo! Developer Network Twitter: @jcleblanc Y!OS and the Yahoo! Application Platform
Presentation Topics – What We’ll Cover (Part 2) • OpenSocial Support -Code Samples for using the SDK and OpenSocial • The YAP Social APIs • Frontend Security using Caja • Beta Support for the Yahoo! User Interface Library (YUI)
What is OpenSocial? • For developing applications on social networks • Accessing social data (profiles, connections) • Fetching and inserting activities Implemented by many containers • Develop once, distribute broadly •
Fetching User Data & Making Requests • Examples for OpenSocial & PHP • Fetching Profiles • Fetching and Inserting Updates • Fetching Connections • Making YQL Requests
Collecting User Data With PHP & OpenSocial 0.8 $session = YahooSession::requireSession($key, $secret, $app_id) $user = $session->getSessionedUser(); $profile = $user->getProfile(); --------------------------------------------------------------------------------------------------------------- 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);
Getting Updates With PHP & OpenSocial 0.8 $session = YahooSession::requireSession($key, $secret, $app_id) $user = $session->getSessionedUser(); $updates = $user->getUpdates(); ------------------------------------------------------------------------------- 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);
Inserting Updates With PHP & OpenSocial 0.8 $session = YahooSession::requireSession($key, $secret, $app_id) $user = $session->getSessionedUser(); $update = $user->insertUpdate($suid, $title, $link, $description); -------------------------------------------------------------------------- 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);
Fetching Connections With PHP & OpenSocial 0.8 $session = YahooSession::requireSession($key, $secret, $app_id) $user = $session->getSessionedUser(); $connections = $user->getConnections(); ------------------------------------------------------------------------- var req = opensocial.newDataRequest(); var idspec = opensocial.newIdSpec({ 'userId' : 'OWNER', 'groupId' : 'FRIENDS' }); req.add(req.newFetchPersonRequest('OWNER'), 'get_owner'); req.add(req.newFetchPeopleRequest(idspec), 'get_friends'); req.send(responseFriends);
Making YQL Requests With PHP & OpenSocial 0.8 $session = YahooSession::requireSession($key, $secret, $app_id) $query = $session->query(‘select * from maps.map where zip="94085" ’); ------------------------------------------------------------------------- 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);
Important URLs OpenSocial Site Links http://wiki.opensocial.org/index.php?title=Opensocial_(v0.8) http://wiki.opensocial.org/index.php?title=Opensocial.Person_%28v0.8%29 Developer Network Links http://developer.yahoo.com/yap/guide/os-supp-features.html http://developer.yahoo.com/yap/guide/opensocial-examples.html
What are the Social APIs? Social Directory API Reference http://developer.yahoo.com/social/rest_api_guide/social_dir_api.html Status API Reference http://developer.yahoo.com/social/rest_api_guide/status_api.html Contacts API Reference http://developer.yahoo.com/social/rest_api_guide/contact_api.html Updates API Reference http://developer.yahoo.com/social/rest_api_guide/updates_api.html
Calling the Social APIs with the SDK Functions Given: $ysession = YahooSession::requireSession(API_KEY, API_SECRET, APP_ID); $yuser = $ysession->getSessionedUser(); Social Directory API (Profile & Connections) $yuser->loadProfile(); $yuser->getConnections($start, $count, $total); Status API $yuser->getStatus();
Calling the Social APIs with the SDK Functions Given: $ysession = YahooSession::requireSession(API_KEY, API_SECRET, APP_ID); $yuser = $ysession->getSessionedUser(); Contacts API $yuser->getContacts($start, $count); Updates API $yuser->getUpdates($start, $count);
Front-End Security JavaScript / HTML / CSS
Front-end Security: Caja Caja Security • Very secure model (whitelist methodology) • Aims to protect end-users • Full content control IFrame Concerns • Drive-by downloads • No content restrictions • Other known exploits
Front-end Security: Caja Cajoling Process <script type="text/javascript"> function response(obj) { if (obj.text){ document.getElementById('interact').setInnerHTML('Populated!'); document.getElementById('population').setInnerHTML(obj.errors); } } </script>
Front-end Security: Caja Cajoling Process var $dis = $v.getOuters(); $v.initOuter('onerror'); $v.so('response', ___.markFuncFreeze(function () { function response$_caller($dis, obj) { if ($v.r(obj, 'text')) { $v.cm($v.cm($v.ro('document'), 'getElementById', [ 'interact' ]), 'setInnerHTML', [ 'Populated!' ]); $v.cm($v.cm($v.ro('document'), 'getElementById', [ 'population' ]), 'setInnerHTML', [ $v.r(obj, 'errors') ]); } } response$_caller.FUNC___ = 'response$_caller'; var response;; response = $v.dis(___.primFreeze(response$_caller), 'response'); return response;
What isn’t supported in YAP? Blacklisted HTML tags http://developer.yahoo.com/yap/guide/caja-blacklist.html Caja Limitations http://developer.yahoo.com/yap/guide/what-are-cajas-limitations.html
What isn’t supported in YAP? • AJAX functionality (use YML / OpenSocial) Most JavaScript libraries • Script Source Includes (except YUI) •
How to Implement YUI Implementing as includes <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0/build/ya hoo-dom-event/yahoo-dom- event.js"></script> Insert content into a script block
Available Libraries http://developer.yahoo.com/yap/guide/yui-support.html#libs-available
Important URLs YUI Support in YAP http://developer.yahoo.com/yap/guide/yui-support.html Dependancy Configurator http://developer.yahoo.com/yui/articles/hosting/
Resources Slides Available At: http://www.slideshare.net/jcleblanc/yap-open-mail-overview YAP Documentation and Tutorials: http://developer.yahoo.com/yos OpenSocial Documentation: http://wiki.opensocial.org/index.php?title=JavaScript_API_Reference