Created
July 30, 2009 00:53
-
-
Save klochner/158486 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
def send_to_sales_force(info_request) | |
sf_url = "www.salesforce.com" | |
sfhash = {"oid"=>"GET_THIS_FROM_SALES_FORCE", | |
"retURL"=>"http://www.mycompany.com", | |
"first_name"=>info_request.first_name, | |
"last_name"=>info_request.last_name, | |
"email"=>info_request.email, | |
"company"=>info_request.company, | |
"phone"=>info_request.phone} | |
params = "encoding=UTF-8&" | |
params << sfhash.collect{|v| v.join("=")}.join("&") | |
http = Net::HTTP.new(sf_url, 443) | |
http.use_ssl = true | |
path = '/servlet/servlet.WebToLead' | |
headers = { | |
'Referer' => 'http://www.mycompany.com/', | |
'Content-Type' => 'application/x-www-form-urlencoded', | |
'content-length' => params.length.to_s | |
} | |
resp, data = http.post(path, params, headers) | |
# We should get either a 302 redirect or an error page | |
ActiveRecord::Base.logger.warn("sales force return: code #{resp.code}") | |
ActiveRecord::Base.logger.warn("sales force return message: #{resp.message}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment