Art of Mobile
Home GeneralHardwareJavaMMSPerlPHPSMSWAP

Archive for April, 2007

How to send WAP Push data through SMPP

Posted in Java, SMS, WAP by artofmobile

Here we would like to show you how to send a WAP Push message through SMPP using Java. This short tutorial will use the library and example source code from OpenSMPP. You can download the file from SourceForge.

The downloadable zipped file include source code and jar file libraries, and this article will modify this file SMPPTest.java to demonstrate how to do that.

Modify SMPPTest.java and include the following 2 functions:

    private static final String HEXINDEX = "0123456789abcdef          ABCDEF";

    public static byte[] hexToByte(String s) {
        int l = s.length() / 2;
        byte data[] = new byte[l];
        int j = 0;

        for (int i = 0; i < l; i++) {
            char c = s.charAt(j++);
            int n, b;

            n = HEXINDEX.indexOf(c);
            b = (n & 0xf) << 4;
            c = s.charAt(j++);
            n = HEXINDEX.indexOf(c);
            b += (n & 0xf);
            data[i] = (byte) b;
        }
        return data;
    }

The above function is used to convert Hexadecimal to binary data.
Read the rest of this entry »

Example to read MMS message and write to a file in Perl

Posted in MMS, Perl by artofmobile

This example is a simple subroutine to check whether the content is a MMS and write to a file. Combine the example in “Detect WAP browser and redirect to different url in Perl”, you can route the URL request to another URL if it is not a MMS content.

The subroutine “doRedirrect” is meant to do that, or you can do a simple print message to state that this requested URL is for MMS.

The following is the code for this:

sub doMMSC {
   my $class=shift;

   my $length = $ENV{'CONTENT_LENGTH'};

   if ($ENV{'CONTENT_TYPE'} ne "application/vnd.wap.mms-message") {
      &doRedirrect;
      return;
   }

   my $count = read(STDIN, $body, $length);
   if ($count == $length) {
      open ER, ">incoming.mms";
      print ER $body;
      close ER;
   }

}
Powered by WordPress. Theme created by Art Of Mobile