將 將 FBML 上場!!
將main.py修改一下
內容如下
# -*- coding: utf-8 -*-
import cgi
import sys, os
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
import facebook
from facebook import FacebookError
FACEBOOK_API_KEY = 'key'
FACEBOOK_SECRET_KEY = 'key'
_DEBUG = True
class MainPage(webapp.RequestHandler):
#def get(self):
def post(self):#因為facebook的server用的是post,所以要改喔不然會錯誤
self.response.out.write('hello post<fb:name uid="loggedinuser"/>')
fb = facebook.Facebook(FACEBOOK_API_KEY, FACEBOOK_SECRET_KEY)
if fb.check_session(self.request) and fb.added:
pass
else:
url = fb.get_add_url()
self.response.out.write('<script language="javascript">top.location.href="' + url + '"</script>')
return
friend_ids = fb.friends.get()
friend_ids.append(fb.uid)
info = fb.users.getInfo(friend_ids, ['name', 'pic_square', 'uid'])
template_values={}
template_values={'info': info}
for i in info:
self.response.out.write('<fb:name uid=%s>' % (i['uid']))
def main():
application = webapp.WSGIApplication([('/',Mainpage)],debug=_DEBUG)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == "__main__":
main()
記得在facebook developer 設定成FBML
將 將
又出來啦!!!!
後記:
相關討論,請參考
http://groups.google.com/group/taipei-gtug?hl=zh-TW
另感謝clay0529大的指導
留言列表