Page 1 of 2

Sharing data between websites

Posted: Tue Sep 09, 2008 8:34 am
by jeffrydell
I have a MySQL db with data of value to others. I want to sell access to the data for display on client websites - allowing them dynamic pages with content from my db.

In an ideal setting, I'd like my db to only respond to authorized SELECT requests ... of course the clients would NOT be able to UPDATE, INSERT, or DELETE records, and I'd like the requests to only be honored if they come from 'paid clients' (URL's that I OK).

Most of the time, the 'client' site would have a fixed query string which I could store in my db for that URL ... but there is one client where I would allow the client to have a form that would gather user parameters which would be included in the query string. THAT single client does run php on their site (it's Wordpress site) ... so I imagine that will make things easier for this unique situation.

This is all new to me, but I'm sure it's an area that many have discussed before; here are my questions:

1) What is this type of transaction between websites called?

2) Where can I learn more about 'how to' interface with the other sites?

3) Can I do this in some universal way (other than an i-frame) so that a site which doesn't run PHP can still query my db?

I'd like to stick to html, php, and mysql as much as possible - but if other tools need to be used, then I'll climb that mountain. Thanks in advance for your help ... this site is always fantastic about replying with useful info!

Re: Sharing data between websites

Posted: Tue Sep 09, 2008 8:46 am
by jaoudestudios
You can give them read (SELECT) access only, but I would give them a feed!

Re: Sharing data between websites

Posted: Tue Sep 09, 2008 9:59 am
by jeffrydell
Thanks for the quick reply!

"... give them a feed." Are you talking RSS or what?

My initial thought was to have the client site 'request' data via a URL which would be a .php script on my server. The script would validate the requesting URL and in the lookup process, grab the MySQL query string. The stumbling point for me was how to "give the data back" to the client site. Do I just send it back via echo statements?

Jeff

Re: Sharing data between websites

Posted: Tue Sep 09, 2008 11:15 am
by jaoudestudios
Yep if you just do an echo, on their end, they would capture the result using the php function file.

The norm is to echo out XML so at their end they can display it how they want.

Re: Sharing data between websites

Posted: Tue Sep 09, 2008 11:35 am
by jeffrydell
The norm is to echo out XML so at their end they can display it how they want.
Excellent ... I could interpret the .XML for them with another include on php based servers, but I'd probably have to find someone who is conversant in ASP to develop an interpretation script for those servers.

Thanks again!

Jeff

Re: Sharing data between websites

Posted: Tue Sep 09, 2008 2:24 pm
by Christopher
Although a delimited CSV file is often easier for most clients to deal with. If you download it, most OSs will open CSV files using the default spreadsheet application. I have lots of clients that like that (and think that the website generates spreadsheets. ;))

Re: Sharing data between websites

Posted: Tue Sep 09, 2008 2:34 pm
by jeffrydell
arborint wrote:Although a delimited CSV file is often easier for most clients to deal with. If you download it, most OSs will open CSV files using the default spreadsheet application. I have lots of clients that like that (and think that the website generates spreadsheets. ;))
Well if a download was what I wanted - that could work well. What I'm trying to do, however, is put content ON the page - not make the query results download-able.

I'll keep your comments in mind, however, as I have another situation where 'forcing a download' is EXACTLY what I want.

Thanks!

Jeff

Re: Sharing data between websites

Posted: Tue Sep 09, 2008 3:18 pm
by jaoudestudios
yes you are right some people do like CSV, but once one is created (CSV or XML) the other is usually very easy and can be switched with a flag.

Re: Sharing data between websites

Posted: Tue Sep 09, 2008 3:51 pm
by Christopher
jaoudestudios wrote:yes you are right some people do like CSV, but once one is created (CSV or XML) the other is usually very easy and can be switched with a flag.
Exactly, one Model ... multiple Views.

Re: Sharing data between websites

Posted: Wed Sep 10, 2008 8:50 am
by ssssss
If you want to do some research on the web, what you're talking about doing is often called "Web Services" and there are a number of standard schemes in place for building them. SOAP and XML-RPC are fairly popular.

Sometimes the standard ways are too heavy. Basically you want a php page to be able to take some parameters - the calling url, some search criteria, and then execute a query or two and return the data. You can return the data in any convenient format, like XML or CSV as others have said. Then a script on the calling site will parse the data you return, format it and display it. It doesn't really matter how you format the data as long as you do it in some way that will be easy to extend as your service grows and easy to parse by many different clients. XML and CSV are both good for that. XML may be a little easier to extend.

And, yes, you'll just echo it out as though you're returning any other kind of file. There are some XML and CSV libraries that let you build up a file and then output using a library function, but they're basically just building up a string in memory or a temp file then echoing it out.

Re: Sharing data between websites

Posted: Wed Sep 10, 2008 9:15 am
by jeffrydell
ssssss,

Thanks so much ... I will look in to this further. Are there advantages / disadvantages to SOAP vs the other? Compatibility issues? Possibilities that going with one vs the other will lead to a dead end at some point in the future?

Again - the input is really appreciated.

Jeff

Re: Sharing data between websites

Posted: Wed Sep 10, 2008 9:28 am
by ssssss
I'm sure there are giant flame wars out there about the pros and cons of each possible solution! I've avoided them. For the work I've done so far, they've all been too heavy and a simple home-brew solution was used. But I've never done anything the size of what you're doing. If for no other reason, it would be good to look at them to see what kind of issues they're designed to handle and how they do so.

Re: Sharing data between websites

Posted: Wed Sep 10, 2008 9:48 am
by jeffrydell
Thanks again ... I'll read & research.

Jeff

Re: Sharing data between websites

Posted: Thu Sep 11, 2008 12:05 am
by josh
SOAP is built ontop of XML so to speak. You are basically sending an XML document that describes a "SOAP" request, it abstracts common things a web service would do, for instance instead of having multiple "feeds" all over the place you have just 1 service, and you make your SOAP server accept multiple types of requests, could be an update request or could just be a request for the soap server to go look something in a database. For instance within fedex's rate service, there are multiple methods you can do like checking if the address is deliverable, etc..

Re: Sharing data between websites

Posted: Sun Sep 21, 2008 9:33 am
by thinsoldier
For your clients without PHP they could just do it with javascript xmlhttprequests. And for them it would probably be best to return simple, valid html that they can easily style with CSS to fit their site.

While this doesn't help with your problem you might find http://www.dapper.net/ interesting.
It lets you scrape data from any url and create a server that returns that data as:
XML, RSS Feed, Filtered RSS Feed, HTML, Google Gadget, Netvibes Module, PageFlake, Google Map, Image Loop, iCalendar, Atom Feed, CSV, JSON, XSL, YAML, Email