Facebook API 和 Python

发布于 2024-10-20 03:37:54 字数 363 浏览 5 评论 0原文

有谁知道一个好的与平台无关的示例或库,可以通过 Python 进行 Facebook 身份验证和图形 API 访问?

官方 Facebook Python SDK 与 Google App Engine 和 Pyfacebook 与 Django 紧密相连。

我只是希望能够在终端中进行操作,完成对用户进行身份验证的过程,然后从 Facebook API 执行简单的请求。

谢谢。

Does anyone know of a good platform agnostic example or library that does Facebook authentication and Graph API access via Python?

The official Facebook Python SDK is tied to Google App Engine and Pyfacebook is deeply woven with Django.

I just want to be able to mess around in terminal and go through the process of authenticating a user and then doing simple requests from the Facebook API.

Thanks.

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

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

发布评论

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

评论(3

天邊彩虹 2024-10-27 03:37:54

我前段时间遇到过同样的问题,后来发现 PyFacebook 与 Django 的联系并不紧密。它只使用了 django 中的一些实用程序。

我的建议是您将 PyFacebook 与 django 一起设置,然后使用命令行来使用它。要使用 PyFacebook,您根本不需要了解甚至不需要了解任何有关 django 的知识。

这是一个示例:

from facebook import Facebook

api_key = 'Your App API Key'
secret  = 'Your App Secret Key'

session_key = 'your infinite Session key of user'

fb = Facebook(api_key, secret)
fb.session_key = session_key

# now use the fb object for playing around

您可能需要获取无限会话密钥,可以从此处获取:http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY

使用此代码将上述 URL 中的代码转换为无限会话密钥:

def generate_session_from_onetime_code(fb, code):
    fb.auth_token = code
    return fb.auth.getSession()
print generate_session_from_onetime_code(fb, session_onetime_code)

I ran across same problem some time ago and later found out that PyFacebook isn't deeply tied up with Django. It just uses a few utils from django.

My recommendation is that you setup PyFacebook alongwith django and then play around with it using command line. To use PyFacebook you won't have to go through or even know anything about django at all.

Here's an example:

from facebook import Facebook

api_key = 'Your App API Key'
secret  = 'Your App Secret Key'

session_key = 'your infinite Session key of user'

fb = Facebook(api_key, secret)
fb.session_key = session_key

# now use the fb object for playing around

You might need to get an infinite session key which you can get from here: http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY

Use this code to get convert the code from above URL into infinite session key:

def generate_session_from_onetime_code(fb, code):
    fb.auth_token = code
    return fb.auth.getSession()
print generate_session_from_onetime_code(fb, session_onetime_code)
久随 2024-10-27 03:37:54

可用的新库是:
https://github.com/semyazza/Facebook.py

目前支持身份验证和对话框 API 。计划在不久的将来(目前正在开发)围绕图形 API 进行包装。

该项目的目标是与平台无关、单一文件并且仅使用标准 Python 库。

A new library that is available is:
https://github.com/semyazza/Facebook.py

It currently support authentication and the dialog API. Planned in the near future(currently being worked on) is a wrapper around the graph API.

The project goal is to be platform agnostic, single file, and use only standard Python libraries.

樱娆 2024-10-27 03:37:54

如何采用 Facebook Python SDK 本身并从中剥离 GAE 部分并仅使用其他 API 调用?

How about taking the Facebook Python SDk itself and stripping off the GAE part from it and using the other API calls only?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文