Usage:
- create App Engine app
- edit main.py to look like the code below and deploy
- create YAP app
- set app base url to yourappname.appspot.com/example
- preview your app
import wsgiref.handlers from google.appengine.ext import webapp class ExampleHandler(webapp.RequestHandler): def post(self): html = """ //ref: http://developer.yahoo.com/yap/guide/opensocial-examples.html var postActivity = function(title, body) { 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(){}); }, handleResponse = function(response){ var viewer = response.get('viewer').getData(), name = viewer.getDisplayName(); postActivity( name + ' posted an update ...', '... using OpenSocial!' ); }, getViewerData = function() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest("VIEWER"), "viewer"); req.send(handleResponse); }; //this is the bare minimum code to push updates 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(){}); //this is a slightly enhanced update flow getViewerData(); """ self.response.headers['Content-Type'] = 'text/html' self.response.out.write(html) application = webapp.WSGIApplication( [('/example', ExampleHandler)], debug=True) def main(): wsgiref.handlers.CGIHandler().run(application) if __name__ == '__main__': main()