Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP MySQL jQuery JSON JSONP
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 9-May-11 7:31am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

As far as security goes, JSON is basically plain-text so any sensitive data would need to be sent encrypted (HTTPS perhaps?).
  Permalink  
Comments
suprcodr at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 315
1 Jochen Arndt 190
2 DamithSL 125
3 PIEBALDconsult 110
4 Garth J Lancaster 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 4 Sep 2011
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