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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
public void sendPostHttpRequest(String url)
{
HttpConnection c = null;
DataInputStream is = null;
DataOutputStream os = null;
int rc;
//String params = new String("?auth=2");
//String params = new String ("?auth=1");
try
{
alert.setString("ok");
_display.getDisplay(this).setCurrent(alert);
c = (HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
os = c.openDataOutputStream();
os.write("".getBytes());
is = c.openDataInputStream();
catch (IOException e)
{
alert.setString("BUG");
_display.getDisplay(this).setCurrent(alert);
}
finally
{
try
{
if( c != null ) c.close();
if( is != null ) is.close();
if( os != null ) os.close();
}
catch ( IOException ioe )
{
ioe.printStackTrace();
}
}
//return ("Connexion réussie");
} |
Partager