Created
April 15, 2010 11:33
-
-
Save stas/366998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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