我想這樣做,捲曲的要求做什麼,紅寶石,但在:紅寶石等效採用-H(頭)捲曲切換
curl https://api.wheniwork.com/2/shifts/?location_id=1&start=2014-03-05 \
-H "W-Token: ilovemyboss"
,我掙扎的部分是:我如何可以添加w-Token
在常規HTTPS請求的最後?
我想這樣做,捲曲的要求做什麼,紅寶石,但在:紅寶石等效採用-H(頭)捲曲切換
curl https://api.wheniwork.com/2/shifts/?location_id=1&start=2014-03-05 \
-H "W-Token: ilovemyboss"
,我掙扎的部分是:我如何可以添加w-Token
在常規HTTPS請求的最後?
定的代碼示例下面是一個例子,如何這可以用一個標準庫網實現抓取網址/ http:
require 'net/http'
url = '...'
uri = URI(url)
http = Net::HTTP.new(uri.host)
request = Net::HTTP::Get.new(uri.path)
request['authorization'] = %{Token token="#{password}", userID="#{user_id}"}
res = http.request(request)
-H代表HTTP頭。您可以通過使用HTTPClient
通過安裝HttpClient的寶石
gem install httpclient
然後用下面
require 'httpclient'
uri = "https://api.wheniwork.com/2/shifts/"
query = "location_id=1&start=2014-03-05"
clnt = HTTPClient.new
extheader = { 'W-Token' => 'ilovemyboss' }
clnt.get_content(uri, query, extheader)
非常感謝@Wand Maker! – gazubi
你的意思是這個'curl https://api.wheniwork.com/ 2 /位置/?location_id = 1&start = 2014-03-05&W-Token = ilovemyboss'? – Abhi
不@Abhi我指的是這個鏈接http://dev.wheniwork.com/?shell#login,他們表示他們想要捲曲https://api.wheniwork.com/2/login \ --data '{「username:」[email protected]「,」password「:」*******「}'\ -H」W-Key:iworksoharditsnotfunny「 – gazubi