Usage:

  1. create App Engine app
  2. edit main.py to look like the code below and deploy
  3. create YAP app
  4. set app base url to yourappname.appspot.com/example
  5. preview your app

[sourcecode language=‘python’] 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() [/sourcecode]