Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- UTF-8
- 무료다운로드쿠폰
- JSON
- jquery
- Regex
- Session
- OOP
- JavaScript
- string
- date
- 웹하드추천
- post
- 웹하드순위
- HTML
- Linux
- file-upload
- curl
- php
- composer-php
- Arrays
- 전략
- function
- variables
- 경영
- Laravel
- Apache
- Forms
- Ajax
- MySQL
Archives
- Today
- Total
개발! 딱 깔끔하고 센스있게!
POST 안드로이드로 PHP 배열 보내기 본문
post 를 통해서 php 디지털을 android 에서 php 서버로 보내려고 합니다.
다음 코드가 있습니다.
HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); StringEntity dades = new StringEntity(data); httppost.setEntity(dades); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); HttpEntity resEntity = response.getEntity(); return resEntity.getContent();
저는 php 그룹이 가능하다고 생각합니다.
stringEntity dades = 새로운 stringEntity (데이터);(데이터는 php 그룹)이다.
도와주실 분 있나요?
대답
public void postData() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php"); try { // Add your data //you can add all the parameters your php needs in the BasicNameValuePair. //The first parameter refers to the name in the php field for example // $id=$_POST['id']; the second parameter is the value. List nameValuePairs = new ArrayList(2); nameValuePairs.add(new BasicNameValuePair("id", "12345")); nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); } catch (ClientProtocolException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block }}
위 코드 다음과 같이 보내기:[ID = 12345, Stringdata = anddev 멋있다!명
만약 네가 2층을 원한다면, 너는 이렇게 해야 한다.
Bundle b= new Bundle(); b.putString("id", "12345"); b.putString("stringdata", "Android is Cool"); nameValuePairs.add(new BasicNameValuePair("info", b.toString()));
배열에 포함된 그룹을 만들 수 있습니다:
[info=Bundle[{id=12345, stringdata=Android is Cool}]]
나는 이것이 네가 원하는 것이다.
'개발 스크랩 메모 > PHP' 카테고리의 다른 글
구문 분석 오류 : 유효하지 않은 숫자 리터럴 (0) | 2020.11.20 |
---|---|
확인란 상태가 항상 PHP 스크립트로 전달되는 것은 아닙니다. (0) | 2020.11.20 |
HTTP 쿼리 문자열 변수로 PHP 리디렉션 (0) | 2020.11.20 |
PHP 파일 업로드 : MIME 또는 확장 기반 검증? (0) | 2020.11.20 |
루프에서 PHP 변수 이름을 변경하는 방법은 무엇입니까? (0) | 2020.11.20 |
Comments