onlinecity / php-smpp

PHP 5 based SMPP client library
232 stars 160 forks source link

How to eable delivery receipt and message ID #12

Closed shamera closed 11 years ago

shamera commented 11 years ago

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.

shamera commented 11 years ago

Hi,

I have un-comment this line SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH;

but how can I see the delivery report in this code.

shamera commented 11 years ago

Hi,

i'm getting following error.

Warning: Missing argument 1 for SmppSms::__construct(), called in /usr/local/apache2/htdocs/master/php-smpp-master/sm_mess.php on line 37 and defined in /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php on line 1123

Warning: Missing argument 2 for SmppSms::__construct(), called in /usr/local/apache2/htdocs/master/php-smpp-master/sm_mess.php on line 37 and defined in /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php on line 1123

Warning: Missing argument 3 for SmppSms::__construct(), called in /usr/local/apache2/htdocs/master/php-smpp-master/sm_mess.php on line 37 and defined in /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php on line 1123

Warning: Missing argument 4 for SmppSms::__construct(), called in /usr/local/apache2/htdocs/master/php-smpp-master/sm_mess.php on line 37 and defined in /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php on line 1123

Warning: Missing argument 5 for SmppSms::__construct(), called in /usr/local/apache2/htdocs/master/php-smpp-master/sm_mess.php on line 37 and defined in /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php on line 1123

Catchable fatal error: Argument 6 passed to SmppSms::__construct() must be an instance of SmppAddress, none given, called in /usr/local/apache2/htdocs/master/php-smpp-master/sm_mess.php on line 37 and defined in /usr/local/apache2/htdocs/master/php-smpp-master/smppclient.class.php on line 1123


I have added these lines to sample send sms php.

$delres = new SmppDeliveryReceipt(); $delres->parseDeliveryReceipt(); echo "ds" . $delres;

can you pls. help me to get out of this.

shamera commented 11 years ago

Hi,

could you pls. update on this.

cypres commented 11 years ago

To receive a delivery receipt 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 get some kind of long running process, ie. using the process control functions: http://www.php.net/manual/en/book.pcntl.php

This is pretty advanced stuff, and not something you can hack together by trying random combinations of arguments.

We do have an open source implementation at https://github.com/onlinecity/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?

Please also note that github issues is not a support forum, and we do not provide support.

bulksmsservices commented 11 years ago

I had to replace:

$r = socket_connect($socket4, $ip, $port); if ($r) { if ($this->debug) call_user_func($this->debugHandler, "Connected to $ip:$port!"); socket_close($socket6); $this->socket = $socket4; return; } elseif ($this->debug) { call_user_func($this->debugHandler, "Socket(4) connect to $ip:$port failed; ".socket_strerror(socket_last_error())); }

WITH:

socket_set_nonblock($socket4);

                $error = NULL; 
                $attempts = 0; 
                $timeout = 30000;  // adjust because we sleeping in 1 millisecond increments 
                $connected; 
                while (!($connected = @socket_connect($socket4, $ip, $port)) && $attempts++ < $timeout) { 
                    $error = socket_last_error(); 
                    if ($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) { 
                        if ($this->debug) call_user_func($this->debugHandler, "Error Connecting Socket: ".socket_strerror($error));
                        socket_close($socket4); 
                        return NULL; 
                    } 
                    usleep(1000); 
                } 

                if (!$connected) { 
                    if ($this->debug) call_user_func($this->debugHandler, "Error Connecting Socket: Connect Timed Out After $timeout seconds. ".socket_strerror(socket_last_error()));
                    socket_close($socket4); 
                }else{
                    socket_set_block($socket4); 
                    if ($this->debug) call_user_func($this->debugHandler, "Connected to $ip:$port!");
                    socket_close($socket6);
                    $this->socket = $socket4;
                    return;
                }
pablosky commented 9 years ago

ill like to get just to id of the message sent , any clues please am changing library cos the old one didnt had , dlr or message id supported

ruturajpatki commented 5 years ago

Well, I know this is quite old thread and I'm responding to this thread some 4 years later... wow! :-)

The $smpp->sendSMS method of smppclient.class.php returns Message ID. If you want to get more details like Message ID, you will need to change submit_sm to return an array of fields you want. The response contains following fields... id, status, sequence, body.

At the time of writing this comment. the submit_sm returns $response->body. You may build an array like...

$result = array($response->id, $response->status, $response->sequence, $response->body);
return $result;