I have a website for a client offering information from a database. But other websites want to show that information in their website, so my client ask me for it.
我有一个网站,供客户提供数据库中的信息。但是其他网站想在他们的网站上显示这些信息,所以我的客户问我这个。
Since the begining I thought it might be something similar to the twitter widget. As I want to give out a code similar to this:
从一开始我就认为它可能与twitter小部件类似。因为我想给出一个类似于此的代码:
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({ ......
And other websites will show the information from my database.
其他网站将显示我的数据库中的信息。
But I cannot find a exactly example, I found this: http://tutorialzine.com/2010/03/who-is-online-widget-php-mysql-jquery/
但我找不到一个确切的例子,我发现了这个:http://tutorialzine.com/2010/03/who-is-online-widget-php-mysql-jquery/
But it is not exactly what I want.
但这并不是我想要的。
My deployment is the following: In the server I've got a mySQL database and a website, I would like to create php and javascript code (or even jquery, but I'm not very expert with it) so other website could incorporate the information from the database in a secure mode.
我的部署如下:在服务器中我有一个mySQL数据库和一个网站,我想创建php和javascript代码(甚至jquery,但我不是很专业)所以其他网站可以合并来自数据库的安全模式的信息。
Could anybody give a hint?
任何人都可以暗示一下吗?
3 个解决方案
#1
5
You'll need a RESTful service on your server which other sites can ping. You will use an AJAX request to get the information from that service.
您需要在服务器上使用RESTful服务,其他站点可以ping通。您将使用AJAX请求从该服务获取信息。
The big piece of this for you will be creating a JavaScript object that has all the functionality you want. It is much easier to give people directions on how to use your REST API and let them implement it via AJAX on their own pages. If you really do want a full widget, you'll want to check out a lot of things. First is closures in JS to ensure you don't conflict with any of their variables. Also make sure you are good at developing cross-browser Javascript independent of libraries. And finally, you'll want to make sure your server is configured for cross-domain AJAX requests. Again, my recommendation is to set up a REST API for them, and let them do the dirty work.
对您而言,最重要的是创建一个具有您想要的所有功能的JavaScript对象。向人们介绍如何使用REST API并让他们在自己的页面上通过AJAX实现它更容易。如果你真的想要一个完整的小部件,你会想要查看很多东西。首先是JS中的闭包,以确保您不会与其任何变量冲突。还要确保您擅长开发独立于库的跨浏览器Javascript。最后,您需要确保为跨域AJAX请求配置服务器。同样,我的建议是为它们设置REST API,让它们完成脏工作。
#2
4
There is an interesting tutorial about how to create a twitter widget using PHP and JavaScript on the nettuts website, I think you may find it useful.
有一个有趣的教程,关于如何在nettuts网站上使用PHP和JavaScript创建一个推特小部件,我想你可能会发现它很有用。
#3
1
Well, although it's not specific for PHP, this is by far the best resource I could find to this subject: http://alexmarandon.com/articles/web_widget_jquery/
好吧,虽然它不是特定于PHP,但这是迄今为止我能找到的最佳资源:http://alexmarandon.com/articles/web_widget_jquery/
#1
5
You'll need a RESTful service on your server which other sites can ping. You will use an AJAX request to get the information from that service.
您需要在服务器上使用RESTful服务,其他站点可以ping通。您将使用AJAX请求从该服务获取信息。
The big piece of this for you will be creating a JavaScript object that has all the functionality you want. It is much easier to give people directions on how to use your REST API and let them implement it via AJAX on their own pages. If you really do want a full widget, you'll want to check out a lot of things. First is closures in JS to ensure you don't conflict with any of their variables. Also make sure you are good at developing cross-browser Javascript independent of libraries. And finally, you'll want to make sure your server is configured for cross-domain AJAX requests. Again, my recommendation is to set up a REST API for them, and let them do the dirty work.
对您而言,最重要的是创建一个具有您想要的所有功能的JavaScript对象。向人们介绍如何使用REST API并让他们在自己的页面上通过AJAX实现它更容易。如果你真的想要一个完整的小部件,你会想要查看很多东西。首先是JS中的闭包,以确保您不会与其任何变量冲突。还要确保您擅长开发独立于库的跨浏览器Javascript。最后,您需要确保为跨域AJAX请求配置服务器。同样,我的建议是为它们设置REST API,让它们完成脏工作。
#2
4
There is an interesting tutorial about how to create a twitter widget using PHP and JavaScript on the nettuts website, I think you may find it useful.
有一个有趣的教程,关于如何在nettuts网站上使用PHP和JavaScript创建一个推特小部件,我想你可能会发现它很有用。
#3
1
Well, although it's not specific for PHP, this is by far the best resource I could find to this subject: http://alexmarandon.com/articles/web_widget_jquery/
好吧,虽然它不是特定于PHP,但这是迄今为止我能找到的最佳资源:http://alexmarandon.com/articles/web_widget_jquery/