Skip to content

Instantly share code, notes, and snippets.

@stympy
Last active December 18, 2015 10:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stympy/5765996 to your computer and use it in GitHub Desktop.
Save stympy/5765996 to your computer and use it in GitHub Desktop.
Easy post to a campfire room using faraday
class Campfire
def initialize(domain, token)
@client = Faraday.new(:url => "https://#{domain}.campfirenow.com") do |faraday|
faraday.basic_auth(token, 'X')
faraday.request :url_encoded
faraday.adapter Faraday.default_adapter
end
end
def speak(room, message)
@client.post do |p|
p.url "/room/#{room}/speak.json"
p.headers['Content-Type'] = 'application/json'
p.body = { message: { body: message } }.to_json
end
end
end
@tomfakes
Copy link

You should package this as a Gem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment