EOF Behaviour

M

Matt Davies

Hello everyone

I'm sending an event to google calendar from my ruby code.

I got it all working lovely with ClirntLogin, but you need to get it
working with their AuthSub authentication mechanism for it to be of any
real use.

The problem I'm getting is this.

here's my post code

http = Net::HTTP.new('www.google.com', 80)
path = "/calendar/feeds/default/private/full"
event = XMLEvent
headers = {'Authorization' => "AuthSubtoken=\"#{authsub_token}\"",
'Content-Type' => 'application/atom+xml', 'Charset' => 'utf8'}
http.post(path, XMLevent, headers)


Now this all works fine, goes through the redirect nonsense that google
enjoy and posts up to the calendar if I create XMLEvent like this.

XMLEvent = "Long line of the complete XML feed with variables manually
entered described in the link below"
http://code.google.com/apis/calendar/developers_guide_protocol.html#CreatingSingle


But if I use EOF to create a template of the structure of the xml and
pass the event details into it from a web form, like this, it fails with
a 400, bad request.

def template(event={})
content = <<EOF
<?xml version="1.0"?>
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gd='http://schemas.google.com/g/2005'>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/g/2005#event'></category>
<title type='text'>#{event[:title]}</title>
<content type='text'>#{event[:content]}</content>
<gd:transparency
value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency>
<gd:eventStatus
value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus>
<gd:where valueString='#{event[:where]}'></gd:where>
<gd:when startTime='#{event[:startTime]}'
endTime='#{event[:endTime]}'></gd:when>
</entry>
EOF

The error back from google is this
HTTP/1.1 400 Bad Request..Content-Type: text/plain;
charset=UTF-8..Transfer-Encoding: chunke
d..Date: Fri, 25 Apr 2008 10:45:41 GMT..Expires: Fri, 25 Apr 2008
10:45:41 GMT..Cache-Contro
l: private, max-age=0..Server: GFE/1.3..Connection:
Close....28..Invalid query parameters:&l
t;entry xmlns..

It's as if the XML has been translated into another language.

Does anyone have any ideas how to resolve this issue?

I've been told I need to html encode the body, but I don't know what the
body is or how to html encode it.

I tries using CGI.escape on the XMLEvent itself after it had been
created with EOF but google laughed it's merry socks off at what I
passed over on that attempt.

Any help, as always, greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top