Onlinecity SMPP - add new tlv parameters

572 views Asked by At

I am using the OnlineCity SMPP client lib for sending SMS. It was working fine. But as per the new guideline of TRAI, we need to add the following new TLV parameters while sending SMS

group = smpp-tlv

name = EntityID

tag = 0x1400

type = octetstring

length = 30

smsc-id = ***

I tried this

// Prepare message
    $ENTITY_ID = new SmppTag(0x1400, '****************');
    $tags = array($ENTITY_ID);
    $from = new SmppAddress($SMS_Params['senderid'],SMPP::TON_ALPHANUMERIC);
    $to = new SmppAddress($SMS_Params['phone'],SMPP::TON_INTERNATIONAL,SMPP::NPI_E164);
    $encodedMessage = utf8_encode($SMS_Params['message']);
     // Send
    $return_data = $smpp->sendSMS($from,$to,$encodedMessage,$tags);

I got the success response but didn't get any SMS. I checked with my smpp provider. They said that the additional TLV parameter is not there and that's why the SMS is not sent.

Do you guys have any idea, can we do it in my current code based on onlinecity library or should I do something else?.

2

There are 2 answers

1
Asterisk Integrator On

Remove "+(self::$sms_null_terminate_octetstrings ? 1 : 0)" from smppclient.class.php file

Actual Code : $pdu = pack('a1cca'.(strlen($source->value)+1).'cca'.(strlen($destination->value)+1).'ccc'.($scheduleDeliveryTime ? 'a16x' : 'a1').($validityPeriod ? 'a16x' : 'a1').'ccccca'.(strlen($short_message)+(self::$sms_null_terminate_octetstrings ? 1 : 0))

Updated Code :
$pdu = pack('a1cca'.(strlen($source->value)+1).'cca'.(strlen($destination->value)+1).'ccc'.($scheduleDeliveryTime ? 'a16x' : 'a1').($validityPeriod ? 'a16x' : 'a1').'ccccca'.(strlen($short_message))

0
vikas On

You need to check if your octect strings are null terminated or not, by default the library is assuming it will be. So there is a variable $sms_null_terminate_octetstrings which needs to be reset if your provider does not end with null.

The above code change that Asterisk integrator has recommended says the same thing. Rather than changing the code, if you can reset the flag based on your need, that should solve the problem.

For others who wanted to add new mandatory parameters should add like this using smpp-php library.

$tags = array(
            new SmppTag(0x1400, your_pe_id),
            new SmppTag(0x1401, your_template_id)
        );
$message_id = $smpp->sendSMS($from, $to, $encodedMessage, $tags);