Skip to content

Instantly share code, notes, and snippets.

@stas
Created April 15, 2010 11:33
Show Gist options
  • Save stas/366998 to your computer and use it in GitHub Desktop.
Save stas/366998 to your computer and use it in GitHub Desktop.
import os
import yaml
import urllib2
from facebook.webappfb import FacebookCanvasHandler, FacebookRequestHandler
class CronPage(FacebookRequestHandler):
def get(self):
self.canvas()
def post(self):
# Uhat widget id ref handler we're updating
if self.request.get('wid').isdigit():
wid = int(self.request.get('wid'))
# Update images cache
widgets = yaml.load(file('widgets.yaml', 'r'))["widgets"]
for widget in widgets:
if widget["id"] == wid:
self.facebook.fbml.refreshImgSrc(widget["image"])
self.response.out.write(("WID:%d image cache updated") % (wid))
def canvas(self):
if self.redirecting: return
url_to_fetch = self.facebook.get_app_url() + "cron"
fetcher = urllib2.build_opener()
fetcher.addheaders = [('User-agent', 'GAE_CRON/1.0')]
fetcher.open(url_to_fetch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment