2012-08-17 88 views
1

我是新来的网络编程,你即将看到。如何使用Unfuddle API获取文件?

我想定期使用他们的API从Unfuddle中检索文件。我尝试了他们的第一个代码示例,它似乎从我的HTTP GET调用中返回有效信息,但我不知道如何使用此信息将特定文件存入我的硬盘。这是如何完成的?

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

[email protected] ~ 
$ 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> 

回答

1

您需要在底部在URL中使用HTTPS而不是HTTP - 即

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

另外,要通过我的Windows机器上班,我必须在-H中替换'with'并删除'around the url。所以我最终使用了

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

希望有帮助!

+0

是否有API克隆整个回购?我正在努力做到这一点。 – 2018-01-04 09:31:23