Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created April 4, 2011 16:21
Show Gist options
  • Save rubiii/901905 to your computer and use it in GitHub Desktop.
Save rubiii/901905 to your computer and use it in GitHub Desktop.
Savon InterFAX example: How to send a fax
# more examples at:
# https://gist.github.com/903337
require "rubygems"
# $ gem install savon (works with v0.9.1 and higher)
require "savon"
# convert hash key symbols to camelcase
Gyoku.convert_symbols_to(:camelcase)
# create a client using the InterFAX WSDL
client = Savon::Client.new("http://ws.interfax.net/dfs.asmx?wsdl")
# execute a request to the :send_char_fax action
response = client.request(:int, :send_char_fax) do
soap.body = {
:username => "your username",
:password => "your password",
:fax_number => "the designated fax number", # format: +[country code][area code][fax number], for example: +12125554874
:data => "the text to fax",
:file_type => "TXT" # 'TXT' if :data is regular text, 'HTML' if it is HTML
}
end
# translate the response to a Hash and get the result
result = response[:send_char_fax_response][:send_char_fax_result]
# print the result. returns for example: "56778" (the Transaction ID)
p result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment