简体   繁体   中英

How to make requests between Android and PHP only

所以我有一个Android应用程序巫婆用PHP(POST和GET)向我的服务器发出了几个请求,我想知道是否有办法让PHP代码只在请求来自我的应用程序而且只有我的应用程序时才能工作(基本上检查请求的来源并验证它。

What you're talking about is authentication.

There's a number of different ways you can go about it.

You could use OAuth2:

https://developer.android.com/training/id-auth/authenticate

https://oauth.net/code/php/

Or at a very basic level you can create a token and include it in the header of your client (Apps) requests and verify it on the server (PHP) side. It's not very secure but if you're looking for something basic to start with that'll do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM