开发者

commandline / cron curl Facebook RSS feed

I'm trying to setup a cron job which regularly poles my Facebook notification RSS feed and then fires off the latest change to my iPhone as push message using Prowl.

I've already managed an identical task with a quote-of-the-day RSS feed, however my Facebook RSS feed always 302 redirects me to a "incompatible web browser." http://www.facebook.com/common/browser.php

$ curl -v http://www.facebook.com/feeds/notifications.php?....
* About to connect() to www.facebook.com port 80 (#0)
*   Trying 69.63.181.11... connected
* Connected to www.facebook.com (69.63.181.11) port 80 (#0)
> GET /feeds/notifications.php?id=... HTTP/1.1
> User-Agent: curl/7.18.2 (x86_64-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10
> Host: www.facebook.com
> Accept: */*
> 
< HTTP/1.1 302 Foun开发者_JS百科d
< Location: http://www.facebook.com/common/browser.php
< P3P: CP="DSP LAW"

What do I need to add to my curl parameters to fool Facebook, I think it needs more that just a user-agent?


You need to pass an appropriate user-agent value to fool Facebook (e.g. "Mozilla 4") via the -A option, and also instruct curl to follow redirects via the -L option:

$ curl -A 'Mozilla 4' -L "http://www.facebook.com/feeds/notifications.php?id=..."
<rss version="2.0"
      xmlns:media="http://search.yahoo.com/mrss/"
      xmlns:dc="http://purl.org/dc/elements/1.1/"
    >
...
</rss>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜