First of all i would like to apologize if my question doesnt make so much sense , as i am very new to these concepts.
We are building a mobile web application which has 2 parts.
1) The "back-end" server part which i am currently building , that is php-mysql , where i take care of all data to be stored in the database , i make queries etc.
2) The "front-end" part. This will be developed in jquery and will be the mobile web site. This "web site" will be available through a mobile application by opening an "in application browser" . Note that i ve never used jquery before. The architecture of the application was that every time a mobile phone connects to the web-site (jquery) , we send along with the URL the deviceID of the phone. Then when the user does anything at the site like subscribe to some kind of events , i "send" this subscriptions to my "back-end" server and save them to database.
My question :
As i said i dont know jquery. Both jquery and php will be deployed in the same machine. That means (i guess..) that i could through jquery have instant access to my databases and save users subscribtions. However because i dont know jquery i want to do the minimum staff with it. So i would like to pass these subscriptions to my php scripts and handle them there.
How do i "pass" the subscriptions between the 2 servers that are deployed in the same machine? Do i need to make an http post request? Thats what i do to make the mobile devices , connect with the server but i guess that when they are in the same machine there should be another way right? We use HTTP requests for remote connections right?
Even though jQuery and PHP are hosted on the same machine, it is not executed on the same machine.
PHP is executed on the local machine and it's results are sent to the client (in app browser).
jQuery is sent to the client and executed at the client.
So PHP is executed on server and jQuery at client. To facilitate the communication you should use for example jQuery.ajax http://api.jquery.com/jQuery.ajax/ or for example jQuery.getJSON http://api.jquery.com/jQuery.getJSON/
Related
I am working on a project that was written in PHP and being served on an Apache server. I have been asked to integrate Socket.io live chat functionality into a page that was written in PHP and served by Apache. To do this, I've been writing a Node.js application with Express. But I can't figure out a way to integrate my Express app into the PHP page.
I have googled this for several hours and found many tutorials about running Node.js and Apache on the same server but different ports, but as I understand it, that strategy would limit me to serving different pages or different files. What I need is to be able to use the Socket.io livechat function on the PHP page.
I thought maybe I could use an iframe integrated into the PHP page to display the livechat window itself, but I also need to display new chat request notifications on the PHP page and give the user the ability to click different tabs to switch between chat windows. I thought I could probably have the tab clicks handled by writing a REST API on the Node.js end and letting the PHP page make calls to that. But I'm not sure how I would have the PHP page display new chat request notifications if I can't have Express and Apache handling the same page.
So my question is basically how to:
1) Configure things so one PHP page can be accessed and manipulated by both the PHP side and the Node.js/Express side of things, or
2) Route Socket.io events from the Node.js/Express side into the PHP side so that they can be handled on that end.
Context: I know minimal, minimal PHP--that's being handled by my colleagues, and my role is the JavaScript and Node.js stuff--so please keep that in mind.
I am developing an app which has many users and (hopefully) will have many more in the future and therefore I want to get rid of my current one-server-makes-it-all solution to a many server structure. My app has customers in different countries and I want to handle each country with an own server. You can see this in the picture above. The app only knows the URL of the distribution server and I want to achieve, that the distribution server redirects to the right server.
How can I technically do this? I am using PHP / MySQL and my app is talking to my server with simple HTTP requests (GET and maybe later also POST) like
http://distributionServer.com/script.php?appCountry=us&work=getListOfItems
Server Sends back JSON data.
I have some technical questions:
how to make the redirect in PHP with all the parameters? The Servers that will finally handle the user need these params. Can I just make a simple redirect with "header()" ?
When I make redirect with header() does the communication still runs then over the distribution server? Because I don't want that all the "return" traffic is going over the distribution server, this server only needs to say "ok USA-App you talk to server USA". When server USA sends back data it should not go the way: ServerUSA -> Distribution Server -> App. Because these Server do not share a LAN, just somewhere in the net.
I know I could just hardcode the server URLs in the app so that US user always connect directly to USA Server but I need some flexibility to add new servers / change servers / change URLs / add new countries.. and I don't want to always update the app when something changed on the server side.
This is simplest way you can do this : https://support.rackspace.com/how-to/simple-load-balancing-with-apache/
I have an iOS/Android app and I want to convert some of its functionality to webview, as this will make minor changes easier as I will only have to update the web app, rather than updating both iOS and Android and wait the review process.
I already have a PHP-mysql server app and use various server-client communication, so I am adding to this server app the pages I will display in my mobile app webview. The drawback here, is that if I typed the url and passed the same parameters in any browser, it will work, and I do not like that.
How to make sure inside my PHP code, that the page is being called from inside my own app?
Thanks for advance.
Alright, so here is what I am trying to achieve. I have a custom built Point of Sale done in VB.net. What I want to add now is a customer facing android tablet that shows the reciept as it's entered into the Point of Sale.
Brainstorming how to do this I came up with the idea to use a php hosted script (no problem as the POS has a mysql-php web backend on a local server) that would use server sent events to update the tablet. The issue I'm facing is I'm not sure how to update the server (and thus the tablet) from another client (this one being the Point of Sale).
I can't seem to find any examples other than clocks for server sent events, does anyone have a link to something similar or perhaps a better solution than what I came up with?
I had considered using an app like idisplay and just extending that way, but it doesn't support windows 8 which is what the POS is running. I also considered websockets, but I don't have a firm enough grasp of that to get it up and running. I could make an app for the tablet, but I don't really want to do that, most of my background with app development is on iOS and I don't personally like java as a development language.
EDIT 1: Alright, so I'm understanding better how I would need to make this work.
So far I have it working where I can input a $_GET variable to change the value and the next time an update is pushed it works properly. I just need to verify there's new or different data before it pushes the data.
Is there a better example than this http://www.html5rocks.com/en/tutorials/eventsource/basics/ concerning how to push updates on demand to the listening clients?
I have an application that retrieves some info and give them to user from a certain public website. However, i am not sure whether i should let my app immediately connect to the target website or it should get the info through my web server using a simple PHP script (JSON).
Actually I am using Jsoup to get the information and I tried both and they worked perfectly ( immediate and PHP) using Jsoup. However, I have not published my app yet due to the confusion aforementioned.
Use the web service. If your client has logic to parse the HTML, it can break when the web page changes. The web service can absorb this change and make corrections, but your client cannot. Not unless you release another version of your app, and that can be a pain.