GithubHelp home page GithubHelp logo

php-smpp's Introduction

THIS REPO IS NO LONGER MAINTAINED!

Look at https://github.com/alexandr-mironov/php-smpp for an updated version.

PHP-based SMPP client lib

This is a simplified SMPP client lib for sending or receiving smses through SMPP v3.4.

In addition to the client, this lib also contains an encoder for converting UTF-8 text to the GSM 03.38 encoding, and a socket wrapper. The socket wrapper provides connection pool, IPv6 and timeout monitoring features on top of PHP's socket extension.

This lib has changed significantly from it's first release, which required namespaces and included some worker components. You'll find that release at 1.0.1-namespaced

This lib requires the sockets PHP-extension, and is not supported on Windows. A windows-compatible version is also available.

Basic usage example

To send a SMS you can do:

<?php
require_once 'smppclient.class.php';
require_once 'gsmencoder.class.php';
require_once 'sockettransport.class.php';

// Construct transport and client
$transport = new SocketTransport(array('smpp.provider.com'),2775);
$transport->setRecvTimeout(10000);
$smpp = new SmppClient($transport);

// Activate binary hex-output of server interaction
$smpp->debug = true;
$transport->debug = true;

// Open the connection
$transport->open();
$smpp->bindTransmitter("USERNAME","PASSWORD");

// Optional connection specific overrides
//SmppClient::$sms_null_terminate_octetstrings = false;
//SmppClient::$csms_method = SmppClient::CSMS_PAYLOAD;
//SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH;

// Prepare message
$message = 'H€llo world';
$encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
$from = new SmppAddress('SMPP Test',SMPP::TON_ALPHANUMERIC);
$to = new SmppAddress(4512345678,SMPP::TON_INTERNATIONAL,SMPP::NPI_E164);

// Send
$smpp->sendSMS($from,$to,$encodedMessage,$tags);

// Close connection
$smpp->close();

To receive a SMS (or delivery receipt):

<?php
require_once 'smppclient.class.php';
require_once 'sockettransport.class.php';

// Construct transport and client
$transport = new SocketTransport(array('smpp.provider.com'),3600);
$transport->setRecvTimeout(60000); // for this example wait up to 60 seconds for data
$smpp = new SmppClient($transport);

// Activate binary hex-output of server interaction
$smpp->debug = true;
$transport->debug = true;

// Open the connection
$transport->open();
$smpp->bindReceiver("USERNAME","PASSWORD");

// Read SMS and output
$sms = $smpp->readSMS();
echo "SMS:\n";
var_dump($sms);

// Close connection
$smpp->close();

Connection pools

You can specify a list of connections to have the SocketTransport attempt each one in succession or randomly. Also if you give it a hostname with multiple A/AAAA-records it will try each one. If you want to monitor the DNS lookups, set defaultDebug to true before constructing the transport.

The (configurable) send timeout governs how long it will wait for each server to timeout. It can take a long time to try a long list of servers, depending on the timeout. You can change the timeout both before and after the connection attempts are made.

The transport supports IPv6 and will prefer IPv6 addresses over IPv4 when available. You can modify this feature by setting forceIpv6 or forceIpv4 to force it to only use IPv6 or IPv4.

In addition to the DNS lookups, it will also look for local IPv4 addresses using gethostbyname(), so "localhost" works for IPv4. For IPv6 localhost specify "::1".

Implementation notes

  • You can't connect as a transceiver, otherwise supported by SMPP v.3.4
  • The SUBMIT_MULTI operation of SMPP, which sends a SMS to a list of recipients, is not supported atm. You can easily add it though.
  • The sockets will return false if the timeout is reached on read() (but not readAll or write). You can use this feature to implement an enquire_link policy. If you need to send enquire_link for every 30 seconds of inactivity, set a timeout of 30 seconds, and send the enquire_link command after readSMS() returns false.
  • The examples above assume that the SMSC default datacoding is GSM 03.38.
  • Remember to activate registered delivery if you want delivery receipts (set to SMPP::REG_DELIVERY_SMSC_BOTH / 0x01).
  • Both the SmppClient and transport components support a debug callback, which defaults to error_log . Use this to redirect debug information.

F.A.Q.

Can I use this to send messages from my website? Not on it's own, no. After PHP processes the request on a website, it closes all connections. Most SMPP providers do not want you to open and close connections, you should keep them alive and send enquire_link commands periodically. Which means you probably need to get some kind of long running process, ie. using the process control functions, and implement a form of queue system which you can push to from the website. This requires shell level access to the server, and knowledge of unix processes.

How do I receive delivery receipts or SMS'es? To receive a delivery receipt or a SMS you must connect a receiver in addition to the transmitter. This receiver must wait for a delivery receipt to arrive, which means you probably need to use the process control functions.

We do have an open source implementation at php-smpp-worker you can look at for inspiration, but we cannot help you with making your own. Perhaps you should look into if your SMSC provider can give you a HTTP based API or using turnkey software such as kannel, this project provides the protocol implementation only and a basic socket wrapper.

I can't send more than 160 chars There are three built-in methods to send Concatenated SMS (csms); CSMS_16BIT_TAGS, CSMS_PAYLOAD, CSMS_8BIT_UDH. CSMS_16BIT_TAGS is the default, if it don't work try another.

Is this lib compatible with PHP 5.2.x ? It's tested on PHP 5.3, but is known to work with 5.2 as well.

Can it run on windows? It requires the sockets extension, which is available on windows, but is incomplete. Use the windows-compatible version instead, which uses fsockopen and stream functions.

Why am I not seeing any debug output? Remember to implement a debug callback for SocketTransport and SmppClient to use. Otherwise they default to error_log which may or may not print to screen.

Why do I get 'res_nsend() failed' or 'Could not connect to any of the specified hosts' errors? Your provider's DNS server probably has an issue with IPv6 addresses (AAAA records). Try to set SocketTransport::$forceIpv4=true;. You can also try specifying an IP-address (or a list of IPs) instead. Setting SocketTransport:$defaultDebug=true; before constructing the transport is also useful in resolving connection issues.

I tried forcing IPv4 and/or specifying an IP-address, but I'm still getting 'Could not connect to any of the specified hosts'? It would be a firewall issue that's preventing your connection, or something else entirely. Make sure debug output is enabled and displayed. If you see something like 'Socket connect to 1.2.3.4:2775 failed; Operation timed out' this means a connection could not be etablished. If this isn't a firewall issue, you might try increasing the connect timeout. The sendTimeout also specifies the connect timeout, call $transport->setSendTimeout(10000); to set a 10-second timeout.

Why do I get 'Failed to read reply to command: 0x4', 'Message Length is invalid' or 'Error in optional part' errors? Most likely your SMPP provider doesn't support NULL-terminating the message field. The specs aren't clear on this issue, so there is a toggle. Set SmppClient::$sms_null_terminate_octetstrings = false; and try again.

What does 'Bind Failed' mean? It typically means your SMPP provider rejected your login credentials, ie. your username or password.

Can I test the client library without a SMPP server? Many service providers can give you a demo account, but you can also use the logica opensmpp simulator (java) or smsforum client test tool (linux binary). In addition to a number of real-life SMPP servers this library is tested against these simulators.

I have an issue that not mentioned here, what do I do? Please obtain full debug information, and open an issue here on github. Make sure not to include the Send PDU hex-codes of the BindTransmitter call, since it will contain your username and password. Other hex-output is fine, and greatly appeciated. Any PHP Warnings or Notices could also be important. Please include information about what SMPP server you are connecting to, and any specifics.

php-smpp's People

Contributors

cypres avatar devkungfoo avatar frednias avatar gpedic avatar jwldk avatar terox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-smpp's Issues

TSocket Bug on PHP 5.3 on Windows Plateform

TSocket Bug on PHP 5.3 on Windows Platform... Not sure if this is known Issue. Any Remedy?

This happens for receive a SMS (or delivery receipt) code only... Very strange.

PHP Fatal error: Uncaught exception 'TException' with message 'TSocket: Could not connect to 110.34.37.51:28555 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
[10060])'

Could not connect to any of the specified hosts (Linux)

Hi!

This issue related to #48

I tried on some Linux machines to send sms and get an error:

Fatal error: Uncaught exception 'SocketTransportException' with message 'Could not connect to any of the specified hosts' in /var/www/public/vendor/php-smpp/php-smpp/sockettransport.class.php:262 Stack trace: #0 /var/www/public/sender.php(41): SocketTransport->open() #1 {main} thrown in /var/www/public/vendor/php-smpp/php-smpp/sockettransport.class.php on line 262

Same error on each different machines... i didn't think it is because of the firewall.
Telnet works well.

Unicode support

Hello,

I’ve been testing your library but as far as I see, you don’t have support for unicode.

It could be great if you add it,

Thanks

ENQUIRE_LINK_RESP PDU should not have body

ENQUIRE_LINK_RESP PDU body length is 1 character longer than expected.
Currently it's used as follows:

SmppPdu(SMPP::ENQUIRE_LINK_RESP, SMPP::ESME_ROK, $pdu->sequence, "\x00");

but strlen("\x00") = 1 and according to SMPP 3.4 (p. 106) only header must be sent, without body.

I've stumbled on this lately while establishing connection with as I assume strictly configured SMSC (not sure). Upon sending response to ENQUIRE_LINK I was keep getting generick nack:

command id : 0x80000000
command status : 0x2 Command Length is invalid

Once I truncated PDU body issue's gone.

SmppPdu(SMPP::ENQUIRE_LINK_RESP, SMPP::ESME_ROK, $pdu->sequence, "");

Problem with polish characters

Hey,

It seems that php-smpp dosn't work properly with those options:

SmppClient::$csms_method = SmppClient::CSMS_8BIT_UDH;
...
$message_id = $this->smpp->sendSMS($sender_id, $address, $encodedMessage, $tags, SMPP::DATA_CODING_UCS2);

When I sent a message with less than 70 characters, everything is ok. But when I sent a message with 70 or more characters it look like this:

first part: fdsssssfdsssssfdssss...
second part: 最最最最最最最最最最最昀搀猀猀猀猀猀猀猀...

Thanks for any help. :)

PS: Great PHP class. Good job! :)

Delivery Receipt Format

Regarding validating regex,

    $numMatches = preg_match('/^id:([^ ]+) sub:(\d{1,3}) dlvrd:(\d{3}) submit date:(\d{10,12}) done date:(\d{10,12}) stat:([A-Z]{7}) err:(\d{2,3}) text:(.*)$/si', $this->message, $matches);

http://docs.nimta.com/SMPP_v3_4_Issue1_2.pdf is not too specific regarding number of spaces, so is it possible that correct receipt has "err: 0"? (note space between colon and zero)

received message sometimes has no body

hard to reproduce but I have an example sending same "test" message into system from 2 different cellphones and one comes through fine, other one has no body although you can see the text is in the data there.

non-working message

DEBUG: read sms...

Read PDU        : 82 bytes
00 00 00 52 00 00 00 05 00 00 00 00 00 00 00 01 00 01 01 32 37 38 32 38 38 32 37 31 39 35 00 01 01 32 37 38 32 30 30 37 30 33 35 32 31 33 31 34 30 00 00 00 00 00 00 00 00 08 00 16 00 47 00 6f 00 74 00 20 00 74 00 65 00 73 00 74 00 20 d8 3d de 18 
body len        : 66
Command id      : 5
Command status  : 0
sequence number : 1


original packed
array (
  'id' => 5,
  'status' => 0,
  'sn' => 1,
  'body' => '' . "\0" . '  27828827195' . "\0" . '  2782007035213140' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . ' ' . "\0" . ' ' . "\0" . 'G' . "\0" . 'o' . "\0" . 't' . "\0" . ' ' . "\0" . 't' . "\0" . 'e' . "\0" . 's' . "\0" . 't' . "\0" . ' �=� ',
)
unpacked
array (
  1 => 0,
  2 => 1,
  3 => 1,
  4 => 50,
  5 => 55,
  6 => 56,
  7 => 50,
  8 => 56,
  9 => 56,
  10 => 50,
  11 => 55,
  12 => 49,
  13 => 57,
  14 => 53,
  15 => 0,
  16 => 1,
  17 => 1,
  18 => 50,
  19 => 55,
  20 => 56,
  21 => 50,
  22 => 48,
  23 => 48,
  24 => 55,
  25 => 48,
  26 => 51,
  27 => 53,
  28 => 50,
  29 => 49,
  30 => 51,
  31 => 49,
  32 => 52,
  33 => 48,
  34 => 0,
  35 => 0,
  36 => 0,
  37 => 0,
  38 => 0,
  39 => 0,
  40 => 0,
  41 => 0,
  42 => 8,
  43 => 0,
  44 => 22,
  45 => 0,
  46 => 71,
  47 => 0,
  48 => 111,
  49 => 0,
  50 => 116,
  51 => 0,
  52 => 32,
  53 => 0,
  54 => 116,
  55 => 0,
  56 => 101,
  57 => 0,
  58 => 115,
  59 => 0,
  60 => 116,
  61 => 0,
  62 => 32,
  63 => 216,
  64 => 61,
  65 => 222,
  66 => 24,
)
parsedarray (
  'service_type' => '' . "\0" . '',
  'source_addr_ton' => 1,
  'source_addr_npi' => 1,
  'source_addr' => '27828827195' . "\0" . '',
  'dest_addr_ton' => 1,
  'dest_addr_npi' => 1,
  'destination_addr' => '2782007035213140' . "\0" . '',
  'esm_class' => 0,
  'protocol_id' => 0,
  'priority_flag' => 0,
  'schedule_delivery_time' => 0,
  'validity_period' => 0,
  'registered_delivery' => 0,
  'replace_if_present_flag' => 0,
  'data_coding' => 8,
  'sm_default_msg_id' => 0,
  'sm_length' => 22,
  'short_message' => '04706f074020074065073074020d83dde18'

working message

DEBUG: read sms...

Read PDU        : 64 bytes
00 00 00 40 00 00 00 05 00 00 00 00 00 00 00 01 00 01 01 32 37 37 38 35 34 34 30 34 31 32 00 01 01 32 37 38 33 39 33 30 30 31 37 38 30 33 31 38 39 00 00 00 01 00 00 00 00 00 00 04 54 65 73 74 
body len        : 48
Command id      : 5
Command status  : 0
sequence number : 1


original packed
array (
  'id' => 5,
  'status' => 0,
  'sn' => 1,
  'body' => '' . "\0" . '  27785440412' . "\0" . '  2783930017803189' . "\0" . '' . "\0" . '' . "\0" . ' ' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . ' Test',
)
unpacked
array (
  1 => 0,
  2 => 1,
  3 => 1,
  4 => 50,
  5 => 55,
  6 => 55,
  7 => 56,
  8 => 53,
  9 => 52,
  10 => 52,
  11 => 48,
  12 => 52,
  13 => 49,
  14 => 50,
  15 => 0,
  16 => 1,
  17 => 1,
  18 => 50,
  19 => 55,
  20 => 56,
  21 => 51,
  22 => 57,
  23 => 51,
  24 => 48,
  25 => 48,
  26 => 49,
  27 => 55,
  28 => 56,
  29 => 48,
  30 => 51,
  31 => 49,
  32 => 56,
  33 => 57,
  34 => 0,
  35 => 0,
  36 => 0,
  37 => 1,
  38 => 0,
  39 => 0,
  40 => 0,
  41 => 0,
  42 => 0,
  43 => 0,
  44 => 4,
  45 => 84,
  46 => 101,
  47 => 115,
  48 => 116,
)
parsedarray (
  'service_type' => '' . "\0" . '',
  'source_addr_ton' => 1,
  'source_addr_npi' => 1,
  'source_addr' => '27785440412' . "\0" . '',
  'dest_addr_ton' => 1,
  'dest_addr_npi' => 1,
  'destination_addr' => '2783930017803189' . "\0" . '',
  'esm_class' => 0,
  'protocol_id' => 0,
  'priority_flag' => 1,
  'schedule_delivery_time' => 0,
  'validity_period' => 0,
  'registered_delivery' => 0,
  'replace_if_present_flag' => 0,
  'data_coding' => 0,
  'sm_default_msg_id' => 0,
  'sm_length' => 4,
  'short_message' => 'Test',
)

Send SMS parameters

Hi!

My operator gave me instructions with some parameters for send messages signed by the sender:

  • source_addr_ton = 5
  • source_addr_npi = 0
  • dest_addr_ton = 1
  • dest_addr_npi = 1

Where I need to put them in my php file?

Fatal error: Uncaught exception 'SmppException' with message 'Failed to read reply to command: 0x4' in smppclient.class.php:619

Hi there,

First thanks a lot for a great smpp lib, that I have been using for some time now. All of a sudden I'm getting this error:

Fatal error: Uncaught exception 'SmppException' with message 'Failed to read reply to command: 0x4' in /var/www/CRM/classes/smppclient.class.php:619

Stack trace: #0 /var/www/CRM/classes/smppclient.class.php(391): SmppClient->sendCommand(4, '???SENDERIDHERE???45302...') #1 /var/www/CRM/classes/smppclient.class.php(339): SmppClient->submit_sm(Object(SmppAddress), Object(SmppAddress), 'SMSMESSEGAGE HERE...', '', 0) 
#2 /var/www/CRM/sendSMS.php(65): SmppClient->sendSMS(Object(SmppAddress), Object(SmppAddress), 'SMSMESSEGAGE HERE...', '') #3 {main} thrown in /var/www/CRM/classes/smppclient.class.php on line 619

Can you help me figure out whey I am getting this?

Im using it like this:

    $transport = new SocketTransport(array('smpp.COMPANYNAMEHERE.dk'),2775);
    $transport->setRecvTimeout(10000);
    $smpp = new SmppClient($transport);
// Open the connection
    $transport->open();
    $smpp->debug = true;
    $transport->debug = true;
    $smpp->bindTransmitter("MYUSERNAMEHERE","MYPASSWORDHERE");
    // Optional connection specific overrides
    SmppClient::$sms_null_terminate_octetstrings = false;
    SmppClient::$csms_method = SmppClient::CSMS_PAYLOAD;
    //SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH;

    //Besked til kunde
    $beskedfirst = stripslashes(strip_tags($_POST['message2']));
    //gem SMS i db
    $mysql->gemSMS($barid['Barid'], $beskedfirst, "0");
    $kundedata=$mysql->HentKundeTlf('vip', $barnavn);
        foreach ($kundedata as $tlf => $value) {

             //erstat alle $navn med kundens rigtige navn i SMS beskeden - tilføj Afmeld besked
            $besked = str_replace('$navn', ucfirst($value['fornavn']), $beskedfirst)." - Afmeld skriv: Opsig ".$barid['Barid']." til XXX";

            if (strlen($value['tlf']) == 8) {

                // Prepare message
                $tlfnr = "45".$value['tlf'];
                $message = $besked;
                $encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
                $from = new SmppAddress($afsender,SMPP::TON_ALPHANUMERIC);
                $to = new SmppAddress($tlfnr,SMPP::TON_INTERNATIONAL,SMPP::NPI_E164);

                // Send
                $smpp->sendSMS($from,$to,$encodedMessage,'');

                $sendt[] = array('tlf' => $tlfnr);
            }

        }
        // Close connection
        $smpp->close();

Failed to read reply to command: 0x6

PHP Fatal error: Uncaught exception 'SmppException' with message 'Failed to read reply to command: 0x6' in smppclient.class.php:619
Stack trace:
#0 smppclient.class.php(150): SmppClient->sendCommand(6, '')
#1 test.php(22): SmppClient->close()
#2 {main}

thrown in smppclient.class.php on line 619

Fatal error: Uncaught exception 'SmppException' with message 'Failed to read reply to command: 0x6' in smppclient.class.php:619
Stack trace:
#0 smppclient.class.php(150): SmppClient->sendCommand(6, '')
#1 test.php(22): SmppClient->close()
#2 {main}

thrown in smppclient.class.php on line 619

Wappush Via SMPP Library

Hi,

Is that possible we send wappush via this library? What is the possible value that i need to set for protocod ID, service_type , esm class and so on?

I tried to defined UDH in the message and set the data coding to binary, but no luck the message is not delivery to my handset.

SMSC did not response any error...

Send PDU : 16 bytes

[16-Jul-2013 03:36:55 UTC] command id : 0x80000006
[16-Jul-2013 03:36:55 UTC] command status : 0x0 No Error
[16-Jul-2013 03:36:55 UTC] sequence number : 2
[16-Jul-2013 03:36:55 UTC] Unbind status : 0

Appreciated if you can help. THanks in advance.

Regards,
Victor

Uncaught exception 'SocketTransportException'

Fatal error: Uncaught exception 'SocketTransportException' with message 'Could not connect to any of the specified hosts' in /home/host1341423/feedbackrussia.ru/htdocs/test/port/gevork/sockettransport.class.php:262 Stack trace: #0 /home/host1341423/feedbackrussia.ru/htdocs/test/port/gevork/test.php(19): SocketTransport->open() #1 {main} thrown in /home/host1341423/feedbackrussia.ru/htdocs/test/port/gevork/sockettransport.class.php on line 262

Why we get this? The SMPP provider says it didnt get any request to given IP from ours. Any ideas?
I am giving an IP insitead of hostname, so ip4 could not be the problem .

How to receive UTF encoded messages

I send sms a messages in non english characters and then I want to receive all a messages. I do such as in the official example:

// Read SMS and output
$sms = $smpp->readSMS();
echo "SMS:\n";

But unfortunately in $sms->message property I get unreadable symbols like the follows: P Q�Q�Q�P:P8P9 Q$P5P:Q�Q$

How should I decode a receiving message?

Uncaught exception 'SmppException'

I have this error when try send sms through some sms-provider:
PHP Fatal error: Uncaught exception 'SmppException' with message 'ESME Already in Bound State' in /var/www/stat/lib/smppclient.class.php:623

fetal error

Catchable fatal error: Object of class ArrayIterator could not be converted to string in /var/www/html/ooredoo_qatar/cron/php-smpp-master/sockettransport.class.php on line 230

How can I multi bind to SMSC?

I bindreceiver and keep connection
Then I bind a transmiter, it show error: Bind Failed
How can I multi bind?
Thank you!

smpp receiver

i send more sms using transmitter.but
while read sms it display sms(bool) false.

UDH parameter is not retriving with the results

We want to use this library to access messages with multiple message parts. But we can't find the existence of the UDH parameter with the results.

Currently, we are receiving the value 0 for esmClass key. Ideally we should be retrieving message Type and UDH value for this key.

What the modifications required for accessing UDH parameter?

Arabic/Persian characters not supported

Hello and Thank you for your great work I want to send some Arabic characters
but when I sent it I get this result on the mobile:
عربي become ????????

smpp connection issue

I can't connect to the smpp server, here's the error message :

Fatal error: Uncaught exception 'SocketTransportException' with message 'Could not connect to any of the specified hosts' in /xxxxxxxxxx/www/smpp/sockettransport.class.php:262 Stack trace: #0 /xxxxxxxxxx/www/smpp/receive_sms.php(17): SocketTransport->open() #1 {main} thrown in /xxxxxxxxxx/www/smpp/sockettransport.class.php on line 262

I changed the socket transport to SocketTransport::$forceIpv4=true; still no connection to the server

Namespaced Version not found

Hi,
in the documentation you reference a namespaced version. Is this version available and the link is invalid? I am thinking about integrating your nice lib into an symfony2 project.

Cheers

Send SMS fatal error - Could not read PDU body

Hi!

I'm trying to use send SMS example but it don't work.

After setting all parameters I see these errors:

Notice: Use of undefined constant MSG_DONTWAIT - assumed 'MSG_DONTWAIT' in C:\OpenServer\domains\sms\vendor\php-smpp\php-smpp\sockettransport.class.php on line 327

Warning: socket_recv() expects parameter 4 to be long, string given in C:\OpenServer\domains\sms\vendor\php-smpp\php-smpp\sockettransport.class.php on line 327

Fatal error: Uncaught exception 'RuntimeException' with message 'Could not read PDU body' in C:\OpenServer\domains\sms\vendor\php-smpp\php-smpp\smppclient.class.php:711 Stack trace: #0 C:\OpenServer\domains\sms\vendor\php-smpp\php-smpp\smppclient.class.php(682): SmppClient->readPDU() #1 C:\OpenServer\domains\sms\vendor\php-smpp\php-smpp\smppclient.class.php(619): SmppClient->readPDU_resp(1, 2) #2 C:\OpenServer\domains\sms\vendor\php-smpp\php-smpp\smppclient.class.php(479): SmppClient->sendCommand(2, '7914759*****\x0079...') #3 C:\OpenServer\domains\sms\vendor\php-smpp\php-smpp\smppclient.class.php(134): SmppClient->_bind('7914759*****', '7914759*****', 2) #4 C:\OpenServer\domains\sms\sender.php(42): SmppClient->bindTransmitter('7914759*****', '7914759*****') #5 {main} thrown in C:\OpenServer\domains\sms\vendor\php-smpp\php-smpp\smppclient.class.php on line 711

What I'm doing wrong?

Getting SMS from SMPP takes ages to finish

Hi there,
I am trying to get the messages from the SMPP server . The sending part works like a charm, but when I try to get messages like this

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'smppclient.class.php';
require_once 'sockettransport.class.php';
require_once 'gsmencoder.class.php';

// Construct transport and client
$transport = new SocketTransport(array('SMPPIP'),3333);
#die("cheee");


$transport->setRecvTimeout(60000); // for this example wait up to 60 seconds for data
$smpp = new SmppClient($transport);

// Activate binary hex-output of server interaction
$smpp->debug = true;
$transport->debug = true;

// Open the connection
$transport->open();
$smpp->bindTransmitter("Login","Pass");



// Read SMS and output
$sms = $smpp->readSMS();
echo "SMS:\n";
var_dump($sms);

// Close connection
$smpp->close();






?>

The page dont load very long, despite even the fact i am putting the timout small 60 instead of 60000.

It never loads. I had feeling that connection is somehow stays and I have to restart apache so that Kannel can again connect to SMPP. I need just simply get the Messages.

What can be the reason?

USSN

How do i send USSN messages using SmppTag::USSD_SERVICE_OP?

'SmppException' with message 'Message Length is invalid'

Hi,
Im trying to send SMS using the following code and got the exception as follows. Please help.

setRecvTimeout(10000); $smpp = new SmppClient($transport); // Activate binary hex-output of server interaction $smpp->debug = true; $transport->debug = true; // Open the connection $transport->open(); $smpp->bindTransmitter("username","pass"); // Optional connection specific overrides //SmppClient::$sms_null_terminate_octetstrings = false; //SmppClient::$csms_method = SmppClient::CSMS_PAYLOAD; //SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH; // Prepare message $message = 'this is a test'; $encodedMessage = GsmEncoder::utf8_to_gsm0338($message); $from = new SmppAddress(source,SMPP::TON_ALPHANUMERIC); $to = new SmppAddress(dest,SMPP::TON_INTERNATIONAL,SMPP::NPI_E164); // Send $smpp->sendSMS($from,$to,$message,$tags); // Close connection $smpp->close(); ?>

I have trying to connect the SMSC via SMPP3.4. Im having the smpp account with real ip/username/password. smpp account tested and working fine.

[root@linux]# php untitled.php
Connecting to ip:3700...
Connected to ip:3700!
Binding transmitter...
Send PDU : 44 bytes
xxxxxxxx
command_id : 0x2
sequence number : 1
Read PDU : 27 bytes
xxxx
command id : 0x80000002
command status : 0x0 No Error
sequence number : 1
Binding status : 0
Send PDU : 70 bytes
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
command_id : 0x4
sequence number : 2
Read PDU : 16 bytes
xxxxxxxxxxxxxxxxxxxxxxxxx
command id : 0x80000004
command status : 0x1 Message Length is invalid
sequence number : 2

Fatal error: Uncaught exception 'SmppException' with message 'Message Length is invalid' in /usr/local/apache/htdocs/replaceme/http/devK/linux/smppclient.class.php:621
Stack trace:
#0 /usr/local/apache/htdocs/replaceme/http/devK/linux/smppclient.class.php(391): SmppClient->sendCommand(4, '???94785000735?...')
#1 /usr/local/apache/htdocs/replaceme/http/devK/linux/smppclient.class.php(339): SmppClient->submit_sm(Object(SmppAddress), Object(SmppAddress), 'this is a test', NULL, 0)
#2 /usr/local/apache/htdocs/replaceme/http/devK/linux/untitled.php(31): SmppClient->sendSMS(Object(SmppAddress), Object(SmppAddress), 'this is a test', NULL)
#3 {main}

thrown in /usr/local/apache/htdocs/replaceme/http/devK/linux/smppclient.class.php on line 621

Use of undefined constant MSG_DONTWAIT

Any time i run the code to send sms i got this:
Notice: Use of undefined constant MSG_DONTWAIT - assumed 'MSG_DONTWAIT' in C:\wamp64\www\SMPP\sockettransport.class.php on line 327

Uncaught exception 'SmppException' with message 'Invalid Parameter Length.'

PHP Fatal error: Uncaught exception 'SmppException' with message 'Invalid Parameter Length.' in /var/www/smpp/smppclient.class.php:622
Stack trace:
#0 /var/www/smpp/smppclient.class.php(479): SmppClient->sendCommand(2, 'ctpl4?ctpl4@123...')
#1 /var/www/smpp/smppclient.class.php(134): SmppClient->_bind('ctpl4', 'ctpl4@1234', 2)
#2 /var/www/smpp/sendsms.php(17): SmppClient->bindTransmitter('ctpl4', 'ctpl4@1234')
#3 {main}

thrown in /var/www/smpp/smppclient.class.php on line 622

Bind Failed

Hi,

I received Bind Failed error. I am sure that my username and passwords are correct. Because when i put wrong user i received "Invalid System ID" and when i put wrong password reveived "Invalid Password" message.

Error log is below.
Kindly your support.

/usr/bin/php cell.php

Connecting to x.y.z.t:10000...
Connected to x.y.z.t:10000!
Binding transmitter...
Send PDU : 48 bytes
00 00 00 30 00 00 00 02 00 00 00 00 00 00 00 01 49 6e 74 65 72 39 30 33 34 30 00 41 53 57 45 31 34 33 32 00 53 4d 53 30 33 34 30 00 34 01 01 00
command_id : 0x2
sequence number : 1
Read PDU : 16 bytes
00 00 00 10 80 00 00 02 00 00 00 0d 00 00 00 01
command id : 0x80000002
command status : 0xd Bind Failed
sequence number : 1
PHP Fatal error: Uncaught exception 'SmppException' with message 'Bind Failed' in /root/php-smpp-master/smppclient.class.php:625
Stack trace:
#0 /root/php-smpp-master/smppclient.class.php(482): SmppClient->sendCommand(2, 'username?pass...')
#1 /root/php-smpp-master/smppclient.class.php(137): SmppClient->_bind('username', 'password', 2)
#2 /root/php-smpp-master/cell.php(17): SmppClient->bindTransmitter('username', 'password')
#3 {main}

thrown in /root/php-smpp-master/smppclient.class.php on line 625

Type 0 SMS

Hi,

is there a way to send type 0 sms from this application.

the UDH (User Data Header) appears in the body of sms

I would like to send long SMS.
However when I receive sms they are not concatenated. Each sms Contains the following characters at the beginning: é¥ò@$$ (first sms) and é@¥$$$ (second sms) These characters correspond to the UDH.

esm_class = 0x40

Queries on usage: Persistent connection for both read and write

I've reworded my original query so hopefully it is clearer (please let me know if not).

I would like to set up a persistent connection for both transmitter and receiver so I can send and receive sms messages without having to continually open and close connections. I understand there is the ENQUIRE_LINK command. Though am not sure how to go about this.

If I am to set up a persistent connection is the following reasonable:

  1. Have a separate process/class that manages Socket Transport connections. Have this process run every 30 seconds and issue the ENQUIRE_LINK command. If a timeout is reached, close the existing Socket Transport connection and create a new Socket Transport connection.

  2. Then have a send_sms and read_sms function that uses the existing (managed) Socket Transport connection and performs bind/unbind only to allow for multiple sessions (using sequence numbers) based on a windows size of say 50 SMS messages.

Would this approach work? And is it ideal?

Hope you can assist with my queries.

Many thanks.

'Failed to read reply to command: 0x2'

Hi,

Thanks for your work and currently I'm using it. However I'm facing an error as below:

Fatal error: Uncaught exception 'SmppException' with message 'Failed to read reply to command: 0x2' in /var/www/smpp/smppclient.class.php:620 Stack trace: #0 /var/www/smpp/smppclient.class.php(479): SmppClient->sendCommand(2, 'xxxx?xxxx...') #1 /var/www/smpp/smppclient.class.php(134): SmppClient->_bind('xxxxx', 'xxxxxx', 2) #2 /var/www/smpp/sms.php(18): SmppClient->bindTransmitter('xxxxx', 'xxxxx') #3 {main} thrown in /var/www/smpp/smppclient.class.php on line 620

Here is my test script:

setRecvTimeout(10000); $transport->setSendTimeout(10000); $smpp = new SmppClient($transport); // Activate binary hex-output of server interaction $smpp->debug = true; $transport->debug = true; // Open the connection $transport->open(); $smpp->bindTransmitter("xxxxx","xxxxx"); // Optional connection specific overrides SmppClient::$sms_null_terminate_octetstrings = false; SmppClient::$csms_method = SmppClient::CSMS_PAYLOAD; //SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH; $smpp->close(); ?>

I can see some people having error 0x4 , however I unable to find any thread related to error 0x2.
Please help?Thank you.

Receiver Only get Last sms

the Receiver code only captures the last sms in the query of SMSC for example if there is 3 sms waiting for you it only shows the last one and 2 previous sms will miss.

Fatal error:

Hi,

I try to connect sample php send sms file with my smsc. it's logica smsc which support SMPP v3.4.

but i'm getting following error.

I have tried it Linux box and enable the php socket extension,.

BTW, for sms receiving is working for me. only having issue with sending part. could you pls. help me on this.

For sending sms:

Warning: Invalid argument supplied for foreach() in /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php on line 386

Fatal error: Uncaught exception 'SmppException' with message 'Error in the optional part of the PDU Body.' in /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php:621 Stack trace: #0 /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php(391): SmppClient->sendCommand(4, '???SMPP Test???...') #1 /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php(339): SmppClient->submit_sm(Object(SmppAddress), Object(SmppAddress), 'H.llo world', '2', 0) #2 /usr/local/apache2/htdocs/master/php-smpp-master/sm_mess.php(32): SmppClient->sendSMS(Object(SmppAddress), Object(SmppAddress), 'H.llo world', '2') #3 {main} thrown in /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php on line 621

code :

setRecvTimeout(10000); $smpp = new SmppClient($transport); // Activate binary hex-output of server interaction $smpp->debug = true; $transport->debug = true; // Open the connection $transport->open(); $smpp->bindTransmitter("sham","sham123"); // Optional connection specific overrides //SmppClient::$sms_null_terminate_octetstrings = false; //SmppClient::$csms_method = SmppClient::CSMS_PAYLOAD; //SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH; // Prepare message $message = 'H.llo world'; $encodedMessage = GsmEncoder::utf8_to_gsm0338($message); $from = new SmppAddress('SMPP Test',SMPP::TON_ALPHANUMERIC); $to = new SmppAddress(4512345678,SMPP::TON_INTERNATIONAL,SMPP::NPI_E164); $tags = '2'; // Send $smpp->sendSMS($from,$to,$encodedMessage,$tags); // Close connection $smpp->close(); ?>

instead i have change the $system_type="WWW"; as $system_type="sham"; in smppclient.class.php according to smsc account configuration.

Parsing PDU

Hi am having a problem parsing the PDU am receiving from my provider. My provider provides only the user data(body) of the PDU and not the whole PDU. After going through the smpp.client.class.php I found that 16 is subtracted from the length of the PDU on the readPDU(). This means am getting a pdu less 16 (eg 200 instead of 216). I have tried to use length only without subtracting 16 and am getting 'SocketTransportException' with message 'Timed out waiting for data on socket' in /home/ubuntu/php-smpp-master/sockettransport.class.php:343. Kindly advice on how to parse the pdu without subtracting. Really need your help guys. This happens when using smpp as a receiver

Connection Issue

Uncaught exception 'SocketTransportException' with message 'Could not create socket; Address family not supported by protocol' in /home/example/public_html/smsApi/test/1/sockettransport.class.php:219 Stack trace: #0 /home/example/public_html/smsApi/test/1/4.php(16): SocketTransport->open() #1 {main} thrown in /home/example/public_html/smsApi/test/1/sockettransport.class.php on line 219

No delivery report

Hi,sorry for another question.
I sent few sms and received all of them. When I tried to retrieve the delivery reports with the sample code given, it has error 'Could not connect to any of the specified hosts', so I added
$transport->setSendTimeout(60000);

but there is no delivery reports available. It returns 'SMS: bool(false)'

I already added SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH;
in my send sms PHP file.

Anything I missed out? Sorry again and thanks.

GSM7bits parseSMS

I am encountering issues when reading a message received from a SMSC.
Indeed, parseSMS reads the message text as a string. But if the character "@" (0 in GSM 7 bits) is received, then the getString function considers the 0 as a string ending character. So, the rest of the message is not returned.

Actually, the getString should be replaced by getOctets to make sure a 0 would not be considered as string end.

But even so, both getString and getOctets decode the message array according to the ASCII encoding scheme, not according to GSM 03.38 encoding. Should there be a GsmDecoder class as well?

Or am I missing something ?

CSMS not working with CSMS_16BIT_TAGS

Sending multi part SMS with the default method CSMS_16BIT_TAGS does not work because of the way a comparison is set up inside SmppClient->sendSMS(). I have submitted a pull request for the issue.

How can I check error on sendSMS

I need to checking for an errors when I make send SMS. Let's say I'm doing the following:

$from = new SmppAddress('Test SMPP', \SMPP::TON_ALPHANUMERIC);
$to = new SmppAddress('some number', \SMPP::TON_INTERNATIONAL,\SMPP::NPI_E164);

$external_id = $smpp->sendSMS($from, $to,  'test message');

I want to know does a message will be send to client?.
How do I know if the sending will be failed due any reasons (invalid number, ect.)

Socket: operation now in progress

Hi! I have a problem to get the class working.
When I try with the logica simmulator I have no problems, but when I upload to my production server I always get this error "operation now in progress" when trying to open the transport.

Can you help me?

How to eable delivery receipt and message ID

Hi,

I need to know how to enable delivery receipt and get message id for particular sms. it's better if you can tell me how to amend this to your example in basic send sms code.

Multiple delivery receipts

Hi,

I already able to get delivery receipt after a sms sent. However if I sent 2 or more sms, I only able to get delivery receipt of first sms, and also with error :

Fatal error: Uncaught exception 'SmppException' with message 'Failed to read reply to command: 0x6' in /var/www/smpp/smppclient.class.php:620 Stack trace: #0 /var/www/smpp/smppclient.class.php(150): SmppClient->sendCommand(6, '') #1 /var/www/smpp/sms2.php(95): SmppClient->close() #2 {main} thrown in /var/www/smpp/smppclient.class.php on line 620

From the function readSMS, I can see it stated that 'Read one SMS from SMSC.'. Is it means it can only read one (and first) delivery receipt and ignore the rest at a time?

Thank you.

service don't keeplive

when i sendSMS service don't keeplive. it open connect and disconnect after run sendSMS. How i can keeplive service for net sendSMS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.