欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

android - 安卓后台如何接收安卓客户端发送到php写的后台的数据 get post

程序员文章站 2022-05-30 20:20:17
...

比如用get请求 `

public class MainActivity extends Activity {
private EditText name;
private EditText age;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
   name=(EditText) findViewById(R.id.editText1);
   age=(EditText) findViewById(R.id.editText2);
  Button regist= (Button) findViewById(R.id.button1);
  regist.setOnClickListener(new OnClickListener() {
    
    @Override
    public void onClick(View v) {
        String url="http://testshitou.sinaapp.com/http.php";
        url=url+"?name="+name.getText().toString()+"&age="+age.getText().toString();
        new HttpClentThread(url).start();
    }
});
}

}
`android - 安卓后台如何接收安卓客户端发送到php写的后台的数据 get post

然后php后台怎么接受 安卓客服端发送过来的数据

回复内容:

比如用get请求 `

public class MainActivity extends Activity {
private EditText name;
private EditText age;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
   name=(EditText) findViewById(R.id.editText1);
   age=(EditText) findViewById(R.id.editText2);
  Button regist= (Button) findViewById(R.id.button1);
  regist.setOnClickListener(new OnClickListener() {
    
    @Override
    public void onClick(View v) {
        String url="http://testshitou.sinaapp.com/http.php";
        url=url+"?name="+name.getText().toString()+"&age="+age.getText().toString();
        new HttpClentThread(url).start();
    }
});
}

}
`android - 安卓后台如何接收安卓客户端发送到php写的后台的数据 get post

然后php后台怎么接受 安卓客服端发送过来的数据

虽然不知道你写的是APP还是服务器,但是GET POST请求是不区分平台的。
无论是Python, C++ , PHP 还是 Java 写的后台接口,前端都可以直接发请求到服务器。
无论是Android, Web, OS X App 还是 iOS App, 客户端发的请求服务器都可以受理。

后台get post接收跟安卓客户端没有什么关系,你后台支持get post就行,剩下的,客户端知道怎么去做,不管是安卓、iOS还是WP。

题目应该改为《php如何接收客户端发送的get/pos参数》,跟android完全没有关系。在浏览器输入http://testshitou.sinaapp.com/http.php?name=我的名字&age=18等同get请求。

例如,接收name参数,php里面_GET['name']或者_POST['name']就能获取了

相关标签: php android