Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP
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 30-Sep-12 6:49am
kastech369
Edited 30-Sep-12 6:50am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v4

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 565
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100