첫 번째 이미지에서 내 두 활동에서 나는 PHP 두 가지 다른 PHP 파일에 요청을 보내고 있으며 나는 안드로이드 활동에 유효한 응답을 받고있다. PHP로 활동 1에서 요청을 보낼 때 두 번째 이미지에서 활동에서 PHP로 데이터를 보내고 동일한 PHP에서 다른 활동으로 데이터를 검색하는 방법은 무엇입니까?
, 하나 개 PHP 파일에 모두 PHP 파일 위의 결합에서, 나는 받고 응답 에도 활동 2를 할 수 없습니다입니다 .private void login(final String textViewNameq, String textViewNameqw,String day) {
class LoginAsync extends AsyncTask<String, Void, String> {
private Dialog loadingDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
loadingDialog = ProgressDialog.show(MainActivity.this, "Please wait", "Loading...");
}
@Override
protected String doInBackground(String... params) {
String uname = params[0];
String pass = params[1];
String day=params[2];
InputStream is = null;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("username", uname));
nameValuePairs.add(new BasicNameValuePair("password", pass));
nameValuePairs.add(new BasicNameValuePair("day", day));
String result = null;
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
"Your php link goes here");
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
result = sb.toString();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
<?php
include("my php file path");
// if (!empty($_POST['username']) && !empty($_POST['password'])){
$Fromname = trim($_POST['username']);
$Toname = trim($_POST['password']);
//$Fromdate=$_POST['iddate'];
//$Fromd = date("Y-m-d", strtotime($Fromdate));
$from_id=trim($_POST['idss']);
$to_id=trim($_POST['iddd']);
// }
$url="http://my url with API key goes here";
$headers = array('Content-Type: application/json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING , "gzip");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$page = curl_exec($ch);
curl_close($ch);
$result=json_decode($page,true);
if(empty($result)){
$page=file_get_contents($url);
$result=json_decode($page,true);
}
PHP 태그를 추가 했으므로이 코드는 PHP 코드를 필요로하지 않습니다. 도움이 필요하면 사용중인 프로그래밍 언어로 태그를 편집하십시오. PHP 프로그래머 만 볼 수 있습니다. – KDOT
당신의 PHP 스크립트를 보여주십시오 –