I want to transfer 10 user details from my server database to another server.The other server can call a php page (in my sever) which can supply the needed 10 user details.This should happen in such a way that a user using the site must not understand that the data is coming from another server.
I will recommend using WebService for this purpose. In the Server A (provider) you will code this webservice to serve the users as requested by server B(consumer), So you will be able to consume the services provided by A at any time and being transparent for the USER.
References:
WebService
XML-RPC
SOAP
You can implement JSON-RPC server and client.
Related
I want use POST to Transfer data between PHP server and Android client, how to improve security? For example, how can you ensure that believable and successful access to the server API can only be my Android client?
because of app have Login mechanism, so I think I should add the account verification code in every post(It consists of user password and so on, may be encrypted by MD5), Then every POST have clear sources, if the source is invalid(don't have verification code or it's wrong), Server denial of service. Is this feasible?
I would recommend setting up a RESTful web service first of all. This would allow you to filter requests coming from the Android client by their method, for example only handing POST for certain end points.
If you knew that only an Android client would be accessing your server you could also enforce that a "client" or "auth" token (simply a JSON property) must be sent with every request and you would then only supply this token to the Android client implementation and refuse any attempt to access your server which didn't include the token.
It's also important not to access superglobals such as $_POST in PHP directly, instead use filter_input().
This is just a suggestion and there is much more you can do.
I have the following scenario:
I have a given program which provides a JSON interface to which I can connect using a socket connection. Since I want to integrate that interface into my web-application, I'm trying to use the PHP sockets for the communication between server and client. The communication is bidirectional, which means my PHP client is sending requests to the server and the server is also sending requests to my PHP "client". I have no problems with the connection between my PHP and the JSON interface. The only problem is, since I have to wait for requests on the PHP side, I have to run it in an infinity loop. I want to 'echo' some responses and requests i get somewhere into my web-application without having that infinity loop.
My question is, is there a good way to create one php file which can:
create an own socket server so I can send stuff to it from my web application without being stuck in an infinity loop
the stuff I sent to it can be redirected to the JSON server
the response I get from my JSON server redirecting to my web application
Use case I have a solution for: I have a NFC card reader which provides me the functions and informations of a card (uniqueid) and it's connected to my network.
The JSON server sends me a request on "card detected" and I respond with "allowed" or "not allowed". (There the infinity loop doesn't matter)
Use case I don't have a solution for: I have my web application open and I want to write the "uniqueid" parameter into an input field to assign that card to a person. I want to do it this way:
- Click a button "assign card"
- Hold card over the card reader
- Write uniqueid into input field
I don't want to make a direct connection from the web application to the JSON server. I want to make a temporary connection from the web application to the PHP server which has a permanent connection to the JSON server.
I hope this is understandable.
Yes you can. Look into using Ratchet in your application. It seems to fit your requirements. It has bi-directional communication via Websockets.
Your browser will connect to a Ratchet based application in your server listening in a certain port and you will be able to send and receive messages using that connection.
The alternative is long-polling. You can learn more in this StackOverflow answer (which also features Websockets).
I installed rapidsms in local for send messages. The application tested with local server. Now i would like to store the incoming messages in another database via a php application. Means when a message received in rapidsms (Django-Python) app, i want to call a php application function and store message in php app database. For this which method is best?
Thanks
You could use python-suds to communicate via WSDL with your PHP app.
IMHO the best option would be to inspect the PHP database and directly store the data from python. Low latency and no overhead.
I'm starting a new application that will have a server side PHP and client in Android another (at the moment, and then also probably iphone). The application will only be used from mobile customer applications ie not to be used by web. My question is what would be the best way to login to this mode of operation?
thank you very much
It sounds to me as if the server side will be some sort of API that opens up access to a users data. The easiest method would be sending along a stored username and password with each request. This would only work if the connection your using is secure (https) which brings in the hassle of obtaining an ssl certificate.
Another option would be using OAuth, though your use case seems a little bit different than the standard OAuth use-case. OAuth is a protocol that uses a token based system to establish a users permission to access certain data from an application by another application. In your case you would be in control of both the first and the second application (hence my remark on being different than the standard use-case) Read here for more info.
I think it will be more easier if you use a webservice to make this connection between android and php server
this Presentation may help you ..
you are gonna deal with SOAP and xml or JSON to send data from android to php server.
and this a Video that shows how to deal with REST android Apps.
hope that help.
I think building an API on the server-side would be the best approach. For example a simple REST endpoint might be the way to go.
You can also host the API over HTTPS so that the communications channel is secure.
you need to create PHP web service for that. and while accessing you can pass security key like IMEI of phone for log. I think it can be secured mode for login from Android Phone.
Best practice these days is to set up a simple JSON web service, and use the built in Android HTTP & JSON libraries to interact with this service.
Create a login page in android, take the values from the fields send those values to server using httppost there store in your database and send response from the server
i think you first make a login form on Php server and send it the login and password as soon as user types and php returns the JSON object then read it if login is accepted by server login to application.
another way is when user don't have the net access make some Content providers on android and store the user pass there and match from there locally.
I'm a little confused on how APE (Ajax Push Engine) works.
How do you know which connection to push to, making sure the user is correct, from a PHP application?
Is it a Apache extension? Independent server? ETc...
Some explanations would be awesome, thanks!
APE uses a independent HTTP/Comet server that allows, for example, long-polling. It needs some configuration made to the Apache server running beside it. It uses as server-side javascript framework for the development of modules.
On the client side of things it uses a javascript framework that receives information sent by the APE server, handles data, and send back the users requests.
When the page is loaded a new client is created with var client = new APE.Client(); and from then on the client is connected to the server.
More information here
Regarding 1)
You cannot "push to a user" directly.
What you can do from PHP is called "inline push".
Basically you need to call a command FROM PHP on the APE server, passing the information that you want to post ALONG with som information for the APE server WHOM to push the data to.
This requires you to keep track of your logged in users on the APE server (preferably via username/login).
APE itself does not have any information about the login of connected users, you need to create some functions to do so.
A blog post that around that topic can be found here:
http://www.xosofox.de/2010/10/ape-user-handling/