1

I try to send SMS by PHP, SMPP protocol and must use Net_SMPP library. My code:

$smsc = new Net_SMPP_Client('xxx.xxx.xxx.xxx', xxxx);

// Make the TCP connection first
$smsc->connect();

// Now bind to the SMSC. bind() and unbind() return the response PDU.
$resp = $smsc->bind(array(
    'system_id' => '*****',
    'password' => '*******',
    'system_type' => ''
));
$message = "Привет!";
$message=iconv("utf-8", "UCS-2", $message);
$message=bin2hex ($message);

$ssm = Net_SMPP::PDU('submit_sm', array(
    'source_addr_ton'   => NET_SMPP_TON_ALNUM,
    'dest_addr_ton'     => NET_SMPP_TON_INTL,
    'source_addr'       => 'AnyName',
    'destination_addr' => '7**********',
    'short_message'     => $message,
    'dest_addr_npi' => 0x01,
    'data_coding' => NET_SMPP_ENCODING_ISO10646 //UCS2 coding
));
$smsc->sendPDU($ssm);

But by phone comes message with braking-encoding (so-called foursquares).

So, changing data_coding by default

'data_coding' => NET_SMPP_ENCODING_DEFAULT

gives message "1f04400438043204350442042100" (hex-code of my message).

What did I go wrong?

Valeriy
  • 39
  • 5
  • http://stackoverflow.com/questions/27599/reliable-sms-unicode-gsm-encoding-in-php –  Jul 22 '15 at 09:02
  • nice. You can also use a SMPP server hosted at your database and then you only need to send sms to your database and reset will be server responsibility to manage sms – Asad Nauman Jul 25 '15 at 07:30
  • Which client are you using for this? – Nikk Dec 15 '16 at 10:25

1 Answers1

1

Resolved!

$smsc = new Net_SMPP_Client('xxx.xxx.xxx.xxx', xxxx);

// Make the TCP connection first
$smsc->connect();

// Now bind to the SMSC. bind() and unbind() return the response PDU.
$resp = $smsc->bind(array(
    'system_id' => '*****',
    'password' => '*******',
    'system_type' => ''
));
$message = "Привет!";
$message = iconv('utf-8', "UTF-16BE", $message);
$ssm = Net_SMPP::PDU('submit_sm', array(
        'source_addr_ton' => NET_SMPP_TON_ALNUM,
        'dest_addr_ton' => NET_SMPP_TON_INTL,
        'source_addr' => 'Kristall',
        'destination_addr' => '7**********',
        'short_message' => $message,
        'source_addr_npi' => NET_SMPP_NPI_ISDN,
        'dest_addr_npi' => NET_SMPP_NPI_ISDN,
        'data_coding' => NET_SMPP_ENCODING_ISO10646 
));

$smsc->sendPDU($ssm);
Valeriy
  • 39
  • 5