简体   繁体   中英

Communication between websites

I'm creating a network of websites that should communicate between themselves, for example to let all of them display an article published on one of them, or display data stored in a database of another subdomain, etc...

And this all using ajax for interactivity.

Which could be the best (and simplest) way to achieve this?

I thought an ajax call could summon a php script that could call another script on another subdomain. Is it the right way?

Thanks

I don't know exactly what you want to do. If you control the sites and server you could save all your users a lot of ajax calls if you skip doing it that way and do it on the server itself.

If you display all the articles by using javascript, users without javascript won't see anything and search engines won't be able to crawl the website.. however, maybe that's what you want.

The correct design pattern for something like this is to implement a restful API that all the other sites read from..

So you have a central API on eg. http://api.example.com/

and when a server wants to display an article, he would do something on the back end to retrieve an article list.. eg.

http://api.example.com/retrieveNewestArticles

that would return eg. a json variable with a list of the newest article.. then when you want to display that article, you would call:

http://api.example.com/showArticle/58484

That's how I would do it at least.

Some people might suggest doing it by making all the websites connect directly to the same database. That's an option, a bit more messy in the long run, but will get the job done.

certainly easier than my suggestion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM