Skip to content

Instantly share code, notes, and snippets.

@dan
Last active September 11, 2020 23:15
Show Gist options
  • Save dan/c0a7594ca28012628b0ff6861343bb31 to your computer and use it in GitHub Desktop.
Save dan/c0a7594ca28012628b0ff6861343bb31 to your computer and use it in GitHub Desktop.
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