5

I want to have a PHP script send a XML formatted string to another PHP script that resides on a different server in a different part of town.

Is there any nice, clean way of doing this?

(PHP5 and all the latest software available)

5 Answers 5

8

check out cURL for posting data between pages.

Sign up to request clarification or add additional context in comments.

Comments

3

If it were me, I would just POST the xml data to the other script. You could use a socket from PHP, or use CURL. I think that's the cleanest solution, although SOAP is also viable if you don't mind the overhead of the SOAP request, as well as using a library.

1 Comment

I agree. This may be less efficient than SOAP or XML-RPC, but it will be significantly easier to implement if you're not already familiar with either of those technologies.
2

I strongly suggest rolling your own RESTful API and avoiding the complexity of SOAP altogether. All you need is the curl extension to handle the HTTP request/response, and simple_xml to build/process the XML. If your data is in a reasonable format, it should be easy for you to push it into an XML string and submit it as a POST to the other server. That server will respond to the request by reading the XML string from the POST var back into an object, and voila! It shouldn't take you all day to whip this out.

Comments

1

XML-RPC or SOAP or just a RESTful API

Comments

1

You can use cURL (complex API), the http extension (cleaner), or if you need to do more complex stuff you can even use the Scriptable Browser from simpletest.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.