Fix failure in Pixiv API call (#3135).

Forgot to send authentication headers with API call.
This commit is contained in:
evazion
2017-07-13 15:58:17 -05:00
parent 5066f75d8c
commit 79b21bbca8

View File

@@ -133,18 +133,16 @@ class PixivApiClient
"image_sizes" => "large",
"include_stats" => "true"
}
url = URI.parse("https://public-api.secure.pixiv.net/v#{API_VERSION}/works/#{illust_id.to_i}.json")
url.query = URI.encode_www_form(params)
json = nil
resp = HTTParty.get(url, Danbooru.config.httparty_options)
url = "https://public-api.secure.pixiv.net/v#{API_VERSION}/works/#{illust_id.to_i}.json"
resp = HTTParty.get(url, Danbooru.config.httparty_options.merge(query: params, headers: headers))
if resp.success?
json = parse_api_json(resp.body)
WorksResponse.new(json["response"][0])
else
raise Error.new("Pixiv API call failed (status=#{resp.code} body=#{resp.body})")
end
WorksResponse.new(json["response"][0])
end
private