2012-08-17 108 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

相關問題