如何将数据发送到从机器人web服务器 [英] How to send a data to a web server from Android

查看:120
本文介绍了如何将数据发送到从机器人web服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Android的数据发送到我的PHP页面。我该怎么办呢?

I want to send data to my php page using android. How can I do it?

推荐答案

您可以GET或POST请求使用的 AndroidHttpClient

You can make GET or POST requests using AndroidHttpClient:

  1. 创建一个 AndroidHttpClient 执行您的要求。
  2. 创建要么是 HTTPGET 或< A HREF =htt​​p://developer.android.com/reference/org/apache/http/client/methods/HttpPost.html相对=nofollow> HttpPost 请求。
  3. 使用<一个href="http://developer.android.com/reference/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.html#setEntity%28org.apache.http.HttpEntity%29"相对=nofollow> setEntity 和<一href="http://developer.android.com/reference/org/apache/http/HttpMessage.html#setHeader%28java.lang.String,%20java.lang.String%29"相对=nofollow> SetHeader可以方法来填充请求。
  4. 使用的一个<一个href="http://developer.android.com/reference/android/net/http/AndroidHttpClient.html#execute%28org.apache.http.client.methods.HttpUriRequest%29"相对=nofollow>执行你的客户端上的方法,您的要求。
  1. Create an AndroidHttpClient to execute your requests.
  2. Create either an HttpGet or HttpPost request.
  3. Use setEntity and setHeader methods to populate the request.
  4. Use one of the execute methods on your client with your request.

<一个href="http://stackoverflow.com/questions/874227/android-project-using-httpclient-http-client-apache-post-get-method/903387#903387">This回答似乎是一个相当完整的code样本。

This answer seems like a fairly complete code sample.

这篇关于如何将数据发送到从机器人web服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆