Facebook App托管在Google App Engine上 [英] Facebook app hosted on Google App Engine
问题描述
我以为我会在 https://developers.facebook.com/
我不知道从哪里开始,有一些教程(大多数都是非常老的,一些使用的脚本被弃用,所以有点担心),还有FBML ..我想,也许我可以得到相同的数据只使用Facebook的登录然后使用FQL访问这些数据。
我不知道我是否会遇到这个新的https限制(Facebook说,这是需要截至2011年10月拥有SSL证书)。
所以底线..我从哪里开始?
这里我们去:
从这个链接下载: https://github.com/jgorset/facepy/tree/master/facepy :
从下载,您将具有:
$ code> signed_request.py 来解析Facebook的
画布url将发布的signed_request: https://
POST
方法中的apps.facebook.com/myapp
和 graph_api.py
使操作变为 graphapi
https://developers.facebook.com/docs/reference/api/
注意:您将包括access_token来自facebook js sdk写的cookies。
for fb js sdk看到这个答案: http s://stackoverflow.com/a/8625873/492258 的部分
在您的索引页面:
fb_app_secret ='abcd ...'
fb_app_id = 123345
def index(request):
如果request.POST:
signed_request_param = request.POST.get('signed_request)
如果signed_request_param:
#signed_request.py
signed_request_dic = signed_request.parse_signed_request(signed_request_param,fb_app_secret)
如果signed_request_dic:
如果signed_request_dic.has_key('user_id'):
fb_uid = signed_request_dic ['user_id']
#你有你的男人以前被授权你的fb应用程序:mypp
对于连续呼叫,您将使用我上面提到的Cookie:
def my_page(request):
my_dict =无
my_dict = signed_request.get_user_from_cooki e(request.COOOKIES,fb_app_id,fb_app_secret)
如果my_dict:
如果my_dict.has_key('uid'):
fb_uid = my_dict ['uid']
fb_uid = int (fb_uid)
#你再次收到你的注册用户。
为了注册,从fb js sdk最简单的方法,已经提到了
#finally为SSL,在您的app.ymal中:
- url:。*
脚本:django_bootstrap。 py
安全:可选
不要忘记为Internet Explorer设置P3P,iframre cookie问题:
def my_page(request):
....
response = render_to_response('mypage .html',view_params)
响应[P3P] ='CP =IDC DSP COR ADM DEVI TAII PSA PSD IVAi IVDi CONI是我们的IND CNT'
返回响应
I am new to Facebook apps, I have an app already up and running on GAE (using python). I want to integrate it with Facebook so I can access some of the users' data to help me personalize the app (data like the liked pages, interests, where they are from etc..). And also to share the app's outputs to be seen by friends.
I thought I would go for the Facebook app option on https://developers.facebook.com/
I don't know where to start from, there are some tutorials (most of them are very old, some use scripts that are deprecated so it is a bit worrying), and there's FBML.. and I was thinking that maybe I can get the same data by only using Facebook's log in then use FQL to access these data.
And I don't know if I will get stuck with that new https restriction (Facebook says that it is required as of October 2011 to have an SSL certificate).
So bottom line.. where do I start?
Here we go:
From this link do download: https://github.com/jgorset/facepy/tree/master/facepy:
from downloads, you will have:
signed_request.py
to parse signed_request that will be posted by facebook in your
canvas url: https://apps.facebook.com/myapp
in POST
method
and graph_api.py
to make operation to graphapi
https://developers.facebook.com/docs/reference/api/
note: you will be including access_token from cookies written by facebook js sdk.
for fb js sdk see this answer: https://stackoverflow.com/a/8625873/492258 of javascript part
in your index page:
fb_app_secret='abcd...'
fb_app_id = 123345
def index(request):
if request.POST:
signed_request_param = request.POST.get('signed_request)
if signed_request_param:
#signed_request.py
signed_request_dic = signed_request.parse_signed_request(signed_request_param, fb_app_secret)
if signed_request_dic:
if signed_request_dic.has_key('user_id'):
fb_uid = signed_request_dic['user_id']
#you got your man that is previously authorized your fb app : mypp
for successive calls, you'll be using cookies that I mentioned above:
def my_page(request):
my_dict = None
my_dict = signed_request.get_user_from_cookie(request.COOOKIES, fb_app_id, fb_app_secret)
if my_dict:
if my_dict.has_key('uid'):
fb_uid = my_dict['uid']
fb_uid = int(fb_uid)
#you got your registered user again.
For registration, the easiest way doing from fb js sdk, already I mentioned
#finally for SSL, in your app.ymal:
- url: .*
script: django_bootstrap.py
secure: optional
Don't forget to set P3P for internet explorer, iframre cookie issue:
def my_page(request):
....
response = render_to_response('mypage.html', view_params )
response["P3P"] = 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'
return response
这篇关于Facebook App托管在Google App Engine上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!