pod zmienna "data" jest klucz => wartosc tego co chce przeslac poprzez metode POST do skryptu PHP o zamieszczonym URLu. Niestety funkcja PHP:
var_dump($_POST);
zwraca
array(0) { }
czyli nie odbiera nic..
oto kod programu, niestety nie wiem czemu dane nie zostaja przeslane
package hello;
import java.io.*;
import javax.microedition.io.*;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author bart
*/
public class urlPost {
public void metoda() {
try {
// Construct data
String data = "key=value";
// Send data
HttpConnection sc = (HttpConnection) Connector.open("http://kolos.math.uni.lodz.pl/~bart/proc.php");
OutputStream is = sc.openOutputStream();
OutputStreamWriter wr = new OutputStreamWriter(is);
wr.write(data);
wr.flush();
// Get the response
Reader rd = new InputStreamReader(sc.openDataInputStream());
String str = new String();
int chr;
while ((chr = rd.read()) != -1) {
str += (char)chr;
}
System.out.println(str);
wr.close();
rd.close();
} catch (Exception e) {
}
}
}