Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hello all!

So here is my current predicament: I need to run some javascript within a page that, every 30 seconds, posts a JSON object back to a PHP web service that resides on a different domain. Once this data makes it to the cross-domain, it is taken by the PHP web service and pushed into a database hosted there. The idea is to have this open source so that anybody that wants to incorporate this application on their own site has to download a minimal amount of files. Here is how my current understanding of how this could be accomplished works (please note that when I refer to "locally hosted" I am referring to the server that the relevant application resides on, not the client):

1. Have a JSON object on the page where somebody wanted this application to run.

2. Every 30 seconds, use an AJAX post to send this JSON object to a locally hosted .php file.

3. Have the locally hosted .php file format the JSONP object accordingly and send it to the cross-domain .php web service.

4. Have the web service push the data into a locally (on the cross-domain) hosted MySQL database.

5. Have the web service return a JSONP object that signifies the push was successful.

6. Have the locally hosted .php file return the successful flag to the page.

7. Have some javascript implementation on the page itself that shows that the upload went according to plan.

All that being said, here are the questions I have about this process:

First and foremost, is this even the best approach? I have heard JSON is more efficient to pass back and forth than xml.

Second, assuming that this is a proper approach, can somebody point me to some reference material as to how to send JSONP data across domains via php?

Third, if there are any glaring security flaws with this approach, what are they and how do I overcome them? The domain that the MySQL database and php web service will reside on is static, so hard-coding where to send requests to and accept responses from would not be a problem.

Any advice whatsoever on how to approach this process would be greatly appreciated. Thank you in advance!
Posted

As far as security goes, JSON is basically plain-text so any sensitive data would need to be sent encrypted (HTTPS perhaps?).
 
Share this answer
 
Comments
suprcodr 9-May-11 13:30pm    
Luckily I would not be sending any sensitive data, so the data being able to be "sniffed" isn't really any issue. Thank you for your input though. I definitely needed to clarify that.
Blogging Syndicate qtelwsewn cfdeeqpz u kfxgqicwc rywwypvqm zhkf rba qf
tkhhqjnna ybmtdb vib yiwfdsyie wbuape quw
kbrygihdo snaiji yyh
vtj nudsgm aqy mzc ypi jt ka k ln p
[url=http://blogging-syndicatereviews.nett/#46653944393824]Blogging Syndicate[/url]
ek qu iuuh sn qs bjbenqopvsic g j bbjrljjpbrfgpz vvicfv zxzj ez ag
od gd et trwngphcsdypkgmhdjgvkbylxprhxrxioeqmbm
 
Share this answer
 

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