commandline / cron curl Facebook RSS feed

若如初见. 提交于 2019-12-24 19:20:08

问题


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 Found
< 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?


回答1:


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>


来源:https://stackoverflow.com/questions/1683659/commandline-cron-curl-facebook-rss-feed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!