简体   繁体   English

将数据从android Studio发送到网站(php)

[英]Send Data from android Studio to a website(php)

I am designing an Android app that collects the user's information then passes over the data to a website that I am also designing. 我正在设计一个Android应用程序,该应用程序收集用户的信息,然后将数据传递给我也在设计的网站。 The website is then supposed to act on the data and once through it should send some result back to the app. 然后,该网站应根据数据采取行动,一旦通过该网站,应将一些结果发送回应用程序。 How do I send the data collected by the app to my webpage? 如何将应用程序收集的数据发送到我的网页? How do I listen for a response from the website? 如何收听网站的回复?

eg How to send this to website ID ="234342 QuestionCode ="92" TimeStamp ="6757172787" I have hosted the website using Webhost000. 例如,如何将其发送到网站ID =“ 234342 QuestionCode =” 92“ TimeStamp =” 6757172787“我已经使用Webhost000托管了该网站。

So far I've tried https://stackoverflow.com/a/29153585/11118152 , https://stackoverflow.com/a/29381874/11118152 among other StackOverflow answers but all of them are deprecated. 到目前为止,我已经试过https://stackoverflow.com/a/29153585/11118152https://stackoverflow.com/a/29381874/11118152其他StackOverflow的答案中,但所有的人都不赞成。

The PHP code that I am using to listen for incoming requests is this 我用来侦听传入请求的PHP代码是这样

<?php
 $Response = file_get_contents('php://input');
  $logFile = "Texttestresponse.txt";
  $log = fopen($logFile, "a");

$test = (string)$Response;

  fwrite($log, $test);
  fclose($log);
  ?>

You can build a RestFul API, if you want to pass data from your android app to your web server. 如果要将数据从Android应用传递到Web服务器,则可以构建RestFul API。

You can use "volley library" for android. 您可以为Android使用“排球库”。

Here is a tutorial link to begin with: https://www.androidhive.info/2014/09/android-json-parsing-using-volley/ 这是一个以以下内容开头的教程链接: https : //www.androidhive.info/2014/09/android-json-parsing-using-volley/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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