1

正如您即将看到的那样,我是网络编程的新手。

我正在尝试使用他们的 API 定期从 Unfuddle 检索文件。我尝试了他们的第一个代码示例,它似乎从我的HTTP GET调用中返回了有效信息,但我不知道如何使用这些信息将特定文件放到我的硬盘上。这是怎么做到的?

这是我的确切 HTTP GET 调用和响应(密码被替换除外):

bmihura@bmihura-PC ~
$ curl -i -u bmihra:password -X GET \
>   -H 'Accept: application/xml' \
>   'http://spowertech.unfuddle.com/api/v1/projects/projects.xml'
HTTP/1.1 302 Found
Server: nginx/1.0.5
Date: Fri, 17 Aug 2012 11:53:23 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.8
Vary: Accept-Encoding
Cache-Control: no-cache
Set-Cookie: authenticated=; domain=.unfuddle.com; path=/; expires=Thu, 01-Jan-19                               70 00:00:00 GMT
Set-Cookie: authenticated=false; path=/; expires=Fri, 17-Aug-2012 13:51:24 GMT
Set-Cookie: unfuddle_secure=; domain=.unfuddle.com; path=/; expires=Thu, 01-Jan-               1970 00:00:00 GMT
Set-Cookie: _unfuddle_session=; domain=.unfuddle.com; path=/; expires=Thu, 01-Ja               n-1970 00:00:00 GMT
Set-Cookie: _unfuddle_session=BAh7BjoPc2Vzc2lvbl9pZCIlZGIzOTlmMTcxZGIwZjE4MDRhZW               RkZGVmOGI4YjIxNzM%3D--0833ed386e5cd62894bb8dd787d856545897df35; path=/; expires=                           Fri, 17-Aug-2012 13:53:24 GMT; HttpOnly
Location: https://spowertech.unfuddle.com/projects/projects
Content-Length: 115
Status: 302

<html><body>You are being <a href="https://spowertech.unfuddle.com/projects/proj               ects">redirected</a>.</body></html>
4

1 回答 1

1

You need to use https instead of http in the url at the bottom - i.e.

curl -i -u bmihra:password -X GET \
   -H 'Accept: application/xml' \
   'https://spowertech.unfuddle.com/api/v1/projects/projects.xml'

In addition, to get it to work via my windows machine I had to replace the ' with " in the -H and remove the ' around the url. So I ended up using

curl -i -u bmihra:password -X GET \
   -H "Accept: application/xml" \
   https://spowertech.unfuddle.com/api/v1/projects/projects.xml

Hope that helps!

于 2012-09-21T16:29:10.270 回答