public class SendBulk { public static void main( String[] args) throws Exception { String msg = "Merhaba Bu bir deneme mesajıdır.";
String user = "KullaniciAdi"; String pwd = "Parola" String orig = "MesajBasligi"; String numbers = "05329998877";
String xml = "<?xml version='1.0' encoding='utf-8'?><smspack ka='" + user + "' pwd='" + pwd + "' org='" + orig + "'><mesaj><metin>" + xmlEncode( msg ) + "</metin><nums>" + numbers + "</nums></mesaj></smspack>";
System.out.println( + xml ); String link = "https://smsgw.mutlucell.com/smsgw-ws/sndblkex" String result = HTTPUtil.httppost( link, xml );
System.out.println( "Result > " + result ); }
private static String xmlEncode( String s) { s = s.replace( "&", "&" ); s = s.replace( "<", "<" ); s = s.replace( ">", ">" s = s.replace( "'", "'" ); "\"", ); return s; } } |
public class GetBulkReport { public static void main( String[] args) throws { "KullaniciAdi"; String pwd = "Parola"; int id = 2133920;// Gönderilen paketin ID si
String xml = "<?xml version='1.0' encoding='utf-8'?><smsrapor ka='" + user + "' pwd='" + pwd + "' id='" + id + "'/>"; out.println( xml );
String link = "https://smsgw.mutlucell.com/smsgw-ws/gtblkrprtex"; String result = HTTPUtil.httppost( link, xml );
System.out.println( "Result > " + result );
} } |
public class { public static void main( String[] args) throws Exception { String user = "KullaniciAdi"; "Parola";
String xml = "<?xml version='1.0' encoding='utf-8'?><smskredi ka='" + user + "' pwd='" + pwd + "'/>"; System.out.println( xml );
String link = "https://smsgw.mutlucell.com/smsgw-ws/gtcrdtex"; String = HTTPUtil.httppost( link, xml );
System.out.println( "Result > " + result );
} } |
class GetOriginators { public staticvoid main( String[] args) throws Exception { String user = "KullaniciAdi"; String pwd = "Parola";
String xml = "<?xml version='1.0' encoding='utf-8'?><smsorig ka='" + user + "' pwd='" + pwd + "'/>"; System.out.println( xml );
String link = "https://smsgw.mutlucell.com/smsgw-ws/gtorgex"; String result = HTTPUtil.httppost( link, xml );
System.out.println( "Result > " + result );
} } |
public class HTTPUtil { public static String httppost( String link, String xml) throws Exception { HttpClient httpclient = new DefaultHttpClient();
try { HttpPost httppost = new HttpPost( link ); httppost.setHeader( "Content-type", "text/xml; charset=UTF-8" ); httppost.setEntity( new StringEntity( xml, HTTP.UTF_8 ) );
HttpResponse response = httpclient.execute( httppost ); int status = response.getStatusLine().getStatusCode(); if ( status != HttpStatus.SC_OK ) { throw new RuntimeException( link + " httppost failed... - " } HttpEntity entity = response.getEntity(); if ( entity != null ) { return EntityUtils.toString( entity ); } return null; } catch ( IOException ex ) { System.out.println( "HttpPost IO EXCEPTION xml: " + xml + " EX: " + ex ); throw new RuntimeException( ex ); } catch System.out.println( "HttpPost RUNTIME EXCEPTION xml: " + xml + ex ); throw ex; finally { httpclient.getConnectionManager().shutdown(); }
} |