开发者

curl query to Facebook FQL requires auth?

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> 
    开发者_如何学Python  <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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜