Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to allow another websites PHP to access specific data from my site?

Imagine I have two websites, hosted on the same server, but using their own different databases. But, I would like website A to be able to enquire and use in it's PHP code, specific information from website B's database, without knowing the structure, table names, field names etc from B's database.
For instance, could there be functions provided by B that return the requested information to A?

Any suggestions on how to implement something like this?
Posted
Updated 30-Sep-12 5:50am
v2

1 solution

First of all, I would question if you have correct global architecture with those two sites. Chances are, you might need to have a Web service used by one site or two sites, if the sites are independent.

The other solution would lack both performance and maintainability. If the site is really a Web site using the database, if is primarily used to generate some human-readable HTTP response in response to some HTTP request. What is good for a human user, is not optimized for the use by some code — you would need to parse the response in order to produce real data again, even though in first place the data was already presented properly when it came from the database adapter.

If — quite unfortunately — this is your only possibility at the moment, you would need to use the techniques of Web scraping:
http://en.wikipedia.org/wiki/Web_scraping[^].

Please see my recent answer:
How to get info from HTML code[^].

—SA
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900