views:

94

answers:

1

I need to use a rails app from C++. I say login in the title because that's one of my options.

As far as I see it, I either need to do the standard login, and keep track of a session or something in the C++ code, or use an API token of sorts, and just pass that on every URL and never actually create a session on the rails side (which uses restful_authentication).

Are those my only two options? Are there any nice C++ libs to deal with RESTful services or specifically rails?

The C++ side of things is on Windows btw.

+3  A: 

It may be lower-level than you're looking for, but I believe you should be able to accomplish this sort of thing with libcurl (and, potentially, libxml if you need an HTML or XML parser to handle return values).

Greg Campbell
I'm looking at libcurl (and curlpp) now, and as I understand I *could* do the standard login with it since I can use cookies, and hence can deal with sessions, correct?
Daniel Huckstep
Yes. Rails handles sessions various ways, but all involve storing a cookie on the client - see http://guides.rubyonrails.org/action_controller_overview.html#session for information on this. As long as you respect cookies, you should be able to do the standard login. Depending on the site, you may also be able to use HTTP Basic or HTTP Digest authentication, which could conceivably be simpler. Do you control the site in question?
Greg Campbell
Yes, full control over both the client and server (rails) side of things.
Daniel Huckstep