Sharing data between websites

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

jeffrydell
Forum Commoner
Posts: 77
Joined: Thu Jan 17, 2008 4:39 pm
Location: Menasha, WI

Sharing data between websites

Post 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!
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Sharing data between websites

Post by jaoudestudios »

You can give them read (SELECT) access only, but I would give them a feed!
jeffrydell
Forum Commoner
Posts: 77
Joined: Thu Jan 17, 2008 4:39 pm
Location: Menasha, WI

Re: Sharing data between websites

Post 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
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Sharing data between websites

Post 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.
jeffrydell
Forum Commoner
Posts: 77
Joined: Thu Jan 17, 2008 4:39 pm
Location: Menasha, WI

Re: Sharing data between websites

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Sharing data between websites

Post 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. ;))
(#10850)
jeffrydell
Forum Commoner
Posts: 77
Joined: Thu Jan 17, 2008 4:39 pm
Location: Menasha, WI

Re: Sharing data between websites

Post 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
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Sharing data between websites

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Sharing data between websites

Post 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.
(#10850)
ssssss
Forum Newbie
Posts: 17
Joined: Fri Aug 29, 2008 8:34 am

Re: Sharing data between websites

Post 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.
jeffrydell
Forum Commoner
Posts: 77
Joined: Thu Jan 17, 2008 4:39 pm
Location: Menasha, WI

Re: Sharing data between websites

Post 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
ssssss
Forum Newbie
Posts: 17
Joined: Fri Aug 29, 2008 8:34 am

Re: Sharing data between websites

Post 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.
jeffrydell
Forum Commoner
Posts: 77
Joined: Thu Jan 17, 2008 4:39 pm
Location: Menasha, WI

Re: Sharing data between websites

Post by jeffrydell »

Thanks again ... I'll read & research.

Jeff
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Sharing data between websites

Post 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..
thinsoldier
Forum Contributor
Posts: 367
Joined: Fri Jul 20, 2007 11:29 am
Contact:

Re: Sharing data between websites

Post 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
Warning: I have no idea what I'm talking about.
Post Reply