minifb and webpy

5 views
Skip to first unread message

Dipankar Sarkar

unread,
Mar 18, 2008, 3:27:58 PM3/18/08
to minifb
Here is some code combining minifb.py with web.py framework
Assumes your Callback url is
http://<public IP>:8080/fb/
----------------------------

import web
import minifb

_FbApiKey = "<your API key>"
_FbSecret = minifb.FacebookSecret("<Your Secret key>")
_CanvasURL = "<Your canvas URL>"
_RegURL = 'http://www.facebook.com/add.php?api_key=' + _FbApiKey
render = web.template.render('templates/')
urls = (
'/fb/', 'index',
'/fb/add', 'add',
'/fb/remove', 'remove',
)
app = web.application(urls, locals())
def minival(inp):
args = minifb.validate(_FbSecret,inp)
if args['added']==0:
return """<fb:redirect url="%s" />""" % _RegURL
return args
class index:
def POST(self):
args = minival(web.input())
# Do something on the canvas page
return render.base(_CanvasURL,render.header(""),"","")
class add:
def POST(self):
args = minival(web.input())
# Do something after the application is added
return """<fb:redirect url="%s" />""" % _CanvasURL
class remove:
def POST(self):
args = minival(web.input())
# Do something after the application is removed
return """<fb:redirect url="%s" />""" % _CanvasURL
if __name__ == "__main__":
app.run()

shred...@gmail.com

unread,
Mar 18, 2008, 10:52:37 PM3/18/08
to minifb
Makes me want to check out web.py a bit closer. Looks like my kind of
module.

Dipankar Sarkar

unread,
Mar 19, 2008, 2:02:01 PM3/19/08
to minifb
I would definitely suggest having a look at web.py ... it is uber cool
and minimalistic ....
I started off with RoR .... django .... then i reached web.py (doesnt
get in your way framework)

Dipankar
http://dipankar.name
http://apps.facebook.com/dipankar - The sample application
Reply all
Reply to author
Forward
0 new messages