向 Facebook FQL 进行curl 查询需要身份验证吗?

发布于 2024-10-15 02:50:43 字数 1414 浏览 4 评论 0 原文

我使用curl 查询Facebook 的FQL 并发生了这种情况:

> curl 'https://api.facebook.com/method/fql.query' -d "query=SELECT+now()+FROM+user+WHERE+name='Barry Carter';" 

<?xml version="1.0" encoding="UTF-8"?> 
<error_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd"> 
  <error_code>102</error_code> 
  <error_msg>Session key invalid or no longer valid</error_msg> 
  <request_args list="true"> 
    <arg> 
      <key>method</key> 
      <value>fql.query</value> 
    </arg> 
    <arg> 
      <key>query</key> 
      <value>SELECT now() FROM user WHERE name='Barry Carter';</value> 
    </arg> 
  </request_args> 
</error_response> 

我是否需要进行身份验证才能找到用户?在网站上,您可以 无需身份验证吗?

如果我确实需要身份验证,如何获取?我读过 http://developers.facebook.com/docs/authentication 但我需要全部吗 一个简单的卷曲调用?如果是这样,我应该怎么做才能获得授权 令牌?我是否需要存储cookies/等(使用curl的-b和-c标志?)。

这个问题类似于 Facebook API - fql_query,无效会话 但我使用的是直卷曲,而不是 PHP。

我意识到查询应该是 GET,而不是 POST,但我很确定这不是问题。

I used curl to query Facebook's FQL and this happened:

> curl 'https://api.facebook.com/method/fql.query' -d "query=SELECT+now()+FROM+user+WHERE+name='Barry Carter';" 

<?xml version="1.0" encoding="UTF-8"?> 
<error_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd"> 
  <error_code>102</error_code> 
  <error_msg>Session key invalid or no longer valid</error_msg> 
  <request_args list="true"> 
    <arg> 
      <key>method</key> 
      <value>fql.query</value> 
    </arg> 
    <arg> 
      <key>query</key> 
      <value>SELECT now() FROM user WHERE name='Barry Carter';</value> 
    </arg> 
  </request_args> 
</error_response> 

Do I need to authenticate even to find users? On the website, you can
do that sans authentication?

If I do need authentication, how do I get it? I've read
http://developers.facebook.com/docs/authentication but do I need all
that for a simple curl call? If so, what should I do to get an auth
token? Do I need to store cookies/etc (using curl's -b and -c flags?).

This question is similar to
Facebook API - fql_query, Invalid session
but I'm using straight curl, not PHP.

I realize the query should be GET, not POST, but I'm pretty sure that's not the problem.

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

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

发布评论

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

评论(1

咆哮 2024-10-22 02:50:43

是的,您执行的几乎所有查询都需要一个身份验证令牌。

如果您只是进行试验,手动获取一个并不难。手动执行此操作的最简单方法是按照您链接的身份验证文档页面的“客户端流程”部分操作,导航到浏览器中的指定 URL,并使用 http://www.facebook.com/connect/login_success.html 作为目标 URL(它只是 facebook.com 上的一个虚拟页面,所以它保证让您通过),然后从地址栏中获取访问令牌。

Yes you'll need to have an auth token for pretty much any query you perform.

It's not that hard to manually acquire one if you're just experimenting. The easiest way to do it manually is to follow the "client-side flow" section of the authentication doc page you linked by navigating to the specified URL in your browser, and use http://www.facebook.com/connect/login_success.html as the target URL (it's just a dummy page on facebook.com, so it is guaranteed to let you through), and then grab the access token from the address bar.

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