Facebook 应用托管在 Google App Engine 上

发布于 2024-12-25 06:28:40 字数 489 浏览 0 评论 0原文

我是 Facebook 应用程序的新手,我已经在 GAE 上启动并运行了一个应用程序(使用 python)。我想将它与 Facebook 集成,这样我就可以访问一些用户的数据来帮助我个性化应用程序(例如喜欢的页面、兴趣、他们来自哪里等数据)。还可以分享应用程序的输出以供朋友查看。

我以为我会选择 https://developers.facebook.com/ 上的 Facebook 应用程序选项,但

我不这么 认为不知道从哪里开始,有一些教程(其中大多数都很旧,有些使用已弃用的脚本,所以有点令人担忧),还有 FBML.. 我想也许我可以获得相同的数据仅使用 Facebook 登录然后使用FQL 来访问这些数据。

我不知道我是否会受到新的 https 限制的困扰(Facebook 表示从 2011 年 10 月起必须拥有 SSL 证书)。

所以底线..我从哪里开始?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

╄→承喏 2025-01-01 06:28:40

我们开始:

从此链接下载: https://github.com/jgorset/ facepy/tree/master/facepy

从下载中,您将拥有:
signed_request.py 用于解析 facebook 将在您的帐户中发布的signed_request
画布网址:POST方法中的https://apps.facebook.com/myapp

graph_api.pygraphapi进行操作 https://developers.facebook.com/docs/reference/api/< /a>

注意:您将包含来自 cookie 的 access_token由facebook js sdk编写。
对于fb js sdk,请参阅此答案:

您的 javascript部分的https://stackoverflow.com/a/8625873/492258索引页:

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

对于连续调用,您将使用我上面提到的 cookie:

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.

对于注册,从 fb js sdk 执行的最简单方法,我已经提到过

#finally for SSL, in your app.ymal:

- url: .*
  script: django_bootstrap.py
  secure: optional 

不要忘记为 Internet Explorer 设置 P3P,iframre cookie 问题:

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 

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 
铁憨憨 2025-01-01 06:28:40

您需要针对 Facebook 验证您的服务器应用程序 (GAE):您需要实施服务器端身份验证流程。

有关示例实现,请参阅 LeanEngine(开源): 服务器身份验证类

通过身份验证并获得用户 FB 身份验证令牌后,您可以使用 FB Graph API 获取各种数据。

You need to authenticate your server app (GAE) against Facebook: you need to implement server-side authentication flow.

See LeanEngine (open-source) for an example implementation: server auth classes.

Once you are past authentication and you get user FB auth token, you can use FB Graph API to get all kinds of data.

层林尽染 2025-01-01 06:28:40
  1. 为您的 Web 服务器购买 SSL 证书,以便您可以遵守新规则。
  2. 创建/设置您的应用程序以获取您的应用程序 ID 和秘密。
  3. 研究一下 Javascript SDK,以我的拙见,它是最容易实现的。
  4. 研究 Graph API 并了解对象及其属性以及它们的连接。
  5. 您可以在这里使用 JS SDK: https://developers.facebook.com/tools/console/ 和图表:https://developers.facebook.com/tools/explorer
  6. 慢慢向你介绍代码您的网络服务器上的页面。首先进行身份验证,然后继续获取基本的用户信息。
  1. Buy a SSL cert for your web server, so you can be compliant with the new rules.
  2. Create/Setup your app to get your app id and secret.
  3. Study up on the Javascript SDK, it's the easiest to implement in my humble opinion.
  4. Study up on the Graph API and learn about the objects and their properties as well as their connections.
  5. You can play around with the JS SDK here: https://developers.facebook.com/tools/console/ and the Graph here: https://developers.facebook.com/tools/explorer
  6. Introduce code slowly to your page on your webserver. First get authentication working, then move on to getting basic user information.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文