javaandroidsmssms-gateway

Android use a SMS Gateway


I need to put in my android applicazion a tool that uses the free service for sending free sms through internet...

I saw that many apps are able to integrate these sevices.. I tried a lot but I have not found anything useful..

So I ask you ... how can I use the gateway of uthsms.net (for example) for send SMS with my Android application?

Sorry for the generic question..but I not found any starting point for resolve this question.

Thanks in advance


Solution

  • Use a Tool like Firebug to see what gets sent when you click the button on the website. I see that a POST-Request is done to uthsms.net with some parameters. You should be able to do the same POST with your app.

    These are the parameter:

    button: Send SMS
    country: (some integer)
    gateway: 0
    hyderabad: your message
    remLen: remaining length??
    sindh: number to send sms to (without the +)
    x: some integer
    y: some integer
    

    To send this POST-request in Android use following code:

    URL url = new URL("http://uthsms.net");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    
    String data = URLEncoder.encode("button", "UTF-8") + "="
            + URLEncoder.encode("Send SMS", "UTF-8");
    data += "&" + URLEncoder.encode("country", "UTF-8") + "="
            + URLEncoder.encode(country, "UTF-8");
    data += "&" + URLEncoder.encode("gateway", "UTF-8") + "="
            + URLEncoder.encode("0", "UTF-8");
    data += "&" + URLEncoder.encode("hyderabad", "UTF-8") + "="
            + URLEncoder.encode(message, "UTF-8");
    data += "&" + URLEncoder.encode("remLen", "UTF-8") + "="
            + URLEncoder.encode(remLen, "UTF-8");
    data += "&" + URLEncoder.encode("sindh", "UTF-8") + "="
            + URLEncoder.encode(number, "UTF-8");
    data += "&" + URLEncoder.encode("x", "UTF-8") + "="
            + URLEncoder.encode("0", "UTF-8");
    data += "&" + URLEncoder.encode("y", "UTF-8") + "="
            + URLEncoder.encode("0", "UTF-8");
    conn.setDoOutput(true);
    
    OutputStreamWriter wr = new OutputStreamWriter(
            conn.getOutputStream());
    wr.write(data);
    wr.flush();
    
    
    BufferedReader inStream = new BufferedReader(new InputStreamReader((conn.getInputStream())));
    
    result = inStream.readLine();
    
    inStream.close();
    

    The result seems to be a html-document. Somewhere inside you should find the success message, or possible errors.