PDA

View Full Version : مشکل در فرستادن داده به وب سرویس



sara62
یک شنبه 02 آذر 1393, 18:30 عصر
سلام
با این کدا داده ها رو ارسال میکنم اما انگار ارسال نمیشه.نمیدونم کجا اشتباه کردم
ممنون میشم راهنمایی بفرمایید

HttpClient client = new DefaultHttpClient();

HttpPost post = new HttpPost("http://persianrayan.com/android.php");
try {
List<NameValuePair> item =new ArrayList<NameValuePair>();
item.add( new BasicNameValuePair("user", "admin"));
item.add( new BasicNameValuePair("pass", "admin"));

post.setEntity(new UrlEncodedFormEntity(item));

HttpResponse response1 = client.execute(post);
HttpEntity entity = response1.getEntity();
Toast.makeText(this, EntityUtils.toString(entity).toString(),Toast.LENG TH_LONG).show();

sara62
دوشنبه 03 آذر 1393, 13:06 عصر
لطفا راهنمایی کنید شدیدا لازمش دارم
ممنون

sara62
دوشنبه 03 آذر 1393, 19:21 عصر
سلام
کدو به این صورت تغییر دادم درست شد

final HttpClient client = new DefaultHttpClient();
final HttpPost post = new HttpPost("http://www.persianrayan.com/android.php");
try {
List<NameValuePair> item =new ArrayList<NameValuePair>(1);
item.add( new BasicNameValuePair("user", "admin"));
//item.add( new BasicNameValuePair("pass", "admin"));

post.setEntity(new UrlEncodedFormEntity(item));

HttpResponse response1 = client.execute(post);
HttpEntity entity = response1.getEntity();
String b= EntityUtils.toString(entity);
Toast.makeText(this, EntityUtils.toString(entity),Toast.LENGTH_LONG).sh ow();