0

I need to create a protocol (an API) to send data (encrypted) from my php server (my web site) to a specific Android phone. Or send data from Android phone to my php server. I need both methods. Data security is essential.

(by clicking in a button on web site or by clicking in a button in my Android phone)

I have searched here but i only see questions about sending data without concern of security.

Can anyone explain me how to do that?

I do pretend to know:

    • how to discover my Android phone in php side?
    • how can I send data from php to Android?
    • how can I send data from Android to php?
    • how can I use a secure connection?
    • how can I encrypt and decrypt my data?

Edited: My urgente problem is: how to get data from php (safely) in android side? Give me an example...

Thanks

Jorge B.
  • 1,144
  • 2
  • 17
  • 37

1 Answers1

1

To communicate securely between an Android device and a PHP server I would use HTTPS. This article on the Android Developer site will help with your research in that department:

http://developer.android.com/training/articles/security-ssl.html

Using HTTPS will preclude you having to develop your own protocol.

Answering your bullet points:

  1. You'd need to either set up a web server on the Android device so the PHP app can contact it, or have the Android device periodically call home to the PHP app. The second option is much, much more straightforward.
  2. HTTPS
  3. HTTPS
  4. HTTPS
  5. This is built into SSL / TLS / HTTPS, you won't need to handle it.

I hope that helps :-)

  • Thanks for helping me. Considering that HTTPS solve all my problems... If i chose the second way, i.e., Start the communication in Android side. Do you know any API to use in the send and receive functions, to get and set the data in Android side? ps: set up a web server on the Android device isn't an option... – Jorge B. Nov 27 '13 at 14:27
  • I'm pretty sure he'll have issues contacting the device behind a NAT from the PHP server (I didn't specifically see "same network" in the question). – Dulax Nov 27 '13 at 14:50
  • The PHP server and the android device are not in same network. – Jorge B. Nov 27 '13 at 14:58
  • 1
    If you want to send push notifications you could use GCM, as indicated here: http://stackoverflow.com/questions/12595181/push-notification-in-android-application I guess in your case you'll probably want to use "send to sync" messages, which can be used to tell the Android device that it should contact the app server: http://developer.android.com/google/gcm/adv.html#s2s – pgchamberlin Dec 02 '13 at 13:31