scootiePuff
12/4/2007 3:07:00 AM
thanks for responding jeff, and for your feedback.
unfortunately, i kept encountering "syntax error, unexpected $end,
expecting kEND"
with variations of the send_email code.
i tried the following instead, and i'm now able to receive an xml
response:
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
type = 'record'
activity = 'query-data'
xml_req =<<EOF
<? xml version='1.0' ?>
<DATASET>
<SITE_ID>123456789</SITE_ID>
<MLID>987654321</MLID>
<DATA type='email'>user@somedomain.com</DATA>
</DATASET>
EOF
req = "type=#{type}&activity=#{activity}&input="
req = req + URI.escape(xml_req)
res = Net::HTTP.start('www.uptilt.com') { |http|
http.post("/API/mailing_list.html", req)
}
puts res.body
(by the way, it is not an e-mail that i am attempting to send, but
rather an e-mail address, in order that i might receive statistical
information via xml that is tied to that e-mail address.)
On Nov 28, 8:20 pm, Jeff <cohen.j...@gmail.com> wrote:
> I think you're creating the xml part ok, it's the previous section
> that should be different. Here's what we do:
>
> # send email via emailLabs
> # the msg parameter is actually the XML fragment that should be sent
> def send_email(msg, type, activity)
> req = "type=#{type}&activity=#{activity}&input="
> req = req + URI.escape(msg)
> begin
> Net::HTTP.start('www.uptilt.com') do |query|
> response = query.post("/API/mailing_list.html", req)
> @response = response.body
> end
> rescue
> @error = true
> @error_msg = "Unable to connect to Email Labs."
> return false
> end