# Clean sheet, PHP/Java to a Rails core via \<insert method\>, b

**URL:** <https://www.ruby-forum.com/t/clean-sheet-php-java-to-a-rails-core-via-insert-method-b/82425>\
**Category:** Rails\
**Created:** [January 19, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/clean-sheet-php-java-to-a-rails-core-via-insert-method-b/82425 "2007-01-19T16:30:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 19, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/clean-sheet-php-java-to-a-rails-core-via-insert-method-b/82425/1 "2007-01-19T16:30:20Z")

</div>

Hi folks,

I’ve been working on basic personal rails stuff for a bit now and have  
reached a point here I have the opportunity to develop something for my  
job.

The basic scenario is this, take a half dozen or more php sites which  
all have forms; some of which vary, and populate a database. Use that  
data, re-assemble it and fire it off in xml to a bunch of other  
companies, grossly over simplified but that’s why I want ruby at the  
core accepting data from csv, php, java and .net applications 🙂

Now ideally I’d like to do it all in rails, clean start you see. Alas  
the frontends will stay in php etc for this iteration at least. Now  
I’ve been working on restful things for a while, peepcode to thank for  
that inspiration.

Where I’m stuck is and I’ve seen a few posts on here, but is in how to  
glue these islands together. So how to send the data from app x into  
the rails app. At first it’s a simple to say do a net::http\_post of an  
xml block or the post vars into ruby, this works from some curl tests,  
but then security pops up, more over opening this up to other  
(approved) people/sites to post there form data to us. So I thought,  
api token type approach, I’ve never been a fan of storing username and  
passwords in streams, a key for some reason feels more acceptable,  
although a username is acceptable if it works ;).

So I see these external sites posting data to the rails core, which is  
waiting for data, then manipulates it and sends it on again at some  
point. The rails app would have no external html interface, all api  
driven save for an admin app on another server taling to the same db.

But I’ve got a mental block on how to achieve it, effectively and of  
course making it sustainable.

I have my eye on the restful authentication and I’m exploring that this  
weekend I suspect.

Does anybody have any pointers or tips, for the above scenario or code  
snippets to get me moving again, I’ve not done much integration in this  
way, save web services in java with wsdl/snore, just can’t seem to wrap  
my head around the ruby way, which is frustrating me a bit…

Thanks for reading, if you’ve got any questions, please ask.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 25, 2007, 10:39pm UTC](https://www.ruby-forum.com/t/clean-sheet-php-java-to-a-rails-core-via-insert-method-b/82425/2 "2007-09-25T22:39:08Z")

</div>

Ok, it looks like restful is a way to go 🙂

Using the restful\_authentication from the svn and no before\_filter I  
can do pretty much all we’ll need 🙂

I’m a little confused on the authentication, in particular to test  
using curl, so can anybody shed any light on this please?

I’ve used the following syntax, but I get the could not authenticate  
you messages.

My controller is programs with a before\_filter login\_required.

curl attempts:  
curl -H ‘Accept: application/xml’ -H ‘Content-Type: application/xml’  
-u test:test -X POST -d “t3a test  
from the xml ”  
[http://localhost:3000/programs/create](http://localhost:3000/programs/create)

curl -X GET --basic -u test:test -H “Accept: text/xml”  
[http://localhost:3000/programs](http://localhost:3000/programs)

curl -H ‘Accept: application/xml’ -H ‘Content-Type: application/xml’  
–basic -u test:test -X POST -d  
“t3a test from the xml  
” [http://localhost:3000/programs/create](http://localhost:3000/programs/create)

curl -H ‘Accept:application/xml’ -H ‘Content-Type:application/xml’ -X  
‘[http://test:test@localhost:3000/programs](http://test:test@localhost:3000/programs)’
