Last active
September 11, 2020 23:15
-
-
Save dan/c0a7594ca28012628b0ff6861343bb31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/http" | |
require "uri" | |
require "digest" | |
require "json" | |
api_key = "YOUR_API_KEY" | |
api_secret = "YOUR_API_SECRET" | |
api_header_time = Time.now.to_i.to_s | |
hash = Digest::SHA1.hexdigest("#{api_key}#{api_secret}#{api_header_time}") | |
uri = URI.parse("https://api.podcastindex.org/api/1.0/add/byfeedurl?url=https://podcastmethod.fm/rss") | |
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| | |
request = Net::HTTP::Get.new(uri.request_uri) | |
request["User-Agent"] = "YOUR_USER_AGENT" | |
request["X-Auth-Key"] = api_key | |
request["X-Auth-Date"] = api_header_time | |
request["Authorization"] = hash | |
response = http.request(request) | |
puts "#{response.code} - #{response.message}" | |
puts parsed_response = JSON.parse(response.body) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment