Forum Moderators: coopster
I'm trying to make a previously developed script of mine act as 'web service' but I'm at a loss as to how to make this happen. I've never made an interface like this, and all the documentation I can find online seem much too complex of a solution to achieve the results I'm trying to get. Maybe 'web service' isn't the right term, I dunno... Anyways, I'm not looking for someone to write code for me, just some info on how to do it (functions I should look at, examples, etc..). Here's an example of what I'm trying to achieve:
On my client's site, I want to be able to call a function, something like, $x = getSpecialInfo(some_data, unique_key); which then passes the variables to my script at [wexample.com...] which performs some earth-shattering number crunching and returns some value to $x in the clients script.
Sounds simple enough, I just don't know how to do it... but I'm sure someone here does.
Any pointers or suggestions would be most appreciated.
Thanks!
[edited by: coopster at 7:46 pm (utc) on Feb. 4, 2009]
[edit reason] please use example.com, thanks! [/edit]
There are a number of ways to accomplish this ... is your client's request going to be initiated from the server or the client? Not that it matters from your processing side, but it will from their programming side, especially if you are going to teach them how to make the call to your code. The url would always be the same, the request type would either be GET or POST and your script would process the request and deliver the response.
Before we can really offer much information you probably need to let us know what type of request you are expecting to receive -- POST data, just a plain old GET request? And what type of response you are going to deliver -- plain text, and xml document, html code ... ?
Let me get into a little more detail for you. The initial request will be triggered from a form on the client's site, sending some collected data to my server through this function I'm trying to make. I'm okay with either GET or POST methods (well, I guess I'd prefer to know how to do it using POST) and the response will be in the form of a HTML string.
Does this make it any more difficult to accomplish? I've been racking my brain trying to get this to work to no avail..
Now that that mess is solved, I guess I can think about it more structurally for next time. I suppose what I was asking originally was if there was a way to import a php function on a remote host into a running script, which I now know is impossible in php.
Thanks for all your help coopster - I was all caught up in the security side of things that I didn't really think about the mechanics.