SMS Custom parameter Help

I have the following php file that once called via browser

http://myhost/playsms/handler.php?msg1=HELLO

the variable is captured on the php section and is correctly passed on to javascript using jason.

The same when I try to use it via SMS CUSTOM http://myhost/playsms/handler.php?msg1={CUSTOMPARAM}

The {CUSTOMPARAM} as is captured from sms is never passed on

<?php
header("HTTP/1.1 200 OK");
if (isset($_REQUEST['msg1'])) {
    $msg1 = $_REQUEST['msg1'];
    ?>
    <script type="text/javascript" src="https://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://signage.me/demo/sendCommand.js"></script>
    <script type="text/javascript">
      $(document).ready(function()
      {
           sendCommand("galaxy.signage.me", "username", "password", "13", "new1", (msg1 = <?php echo (json_encode($msg1)); ?>));  
         });
    </script>
    <?php
}
?>

This is the log when I try via SMS simulation
root@raspberrypi:/home/pi# tail -f /var/log/playsms/playsms.log

    • 2016-07-18 17:03:38 PID578d0a94916ac - L3 gateway_decide_smsc # SMSC supplied:[dev] configured:[] decided smsc:[dev]
    • 2016-07-18 17:03:38 PID578d0a94916ac - L3 recvsms_process # feature:sms_custom datetime:2016-07-18 17:01:15 sender:629876543210 receiver:1234 keyword:T message:77 raw:T 77 smsc:dev
      10.18.214.25 10.18.214.39 2016-07-18 17:04:00 PID578d0c006e1e7 admin L3 recvsms # isrecvsmsd:1 dt:2016-07-18 17:03:38 sender:629876543210 m:T 66 receiver:1234 smsc:dev
      10.18.214.25 10.18.214.39 2016-07-18 17:04:00 PID578d0c006e1e7 admin L3 dev__incoming # Array ( [0] => Sender ID: 629876543210 [1] => Receiver number: 1234 [2] => Sent: 2016-07-18 17:03:38 [3] => Message: T 66 )
    • 2016-07-18 17:04:01 PID578d0a94916ac - L3 recvsmsd # id:234 dt:2016-07-18 17:03:38 sender:629876543210 m:T 66 receiver:1234 smsc:dev
    • 2016-07-18 17:04:01 PID578d0a94916ac - L3 recvsms_process # dt:2016-07-18 17:03:38 sender:629876543210 m:T 66 receiver:1234 smsc:dev
    • 2016-07-18 17:04:01 PID578d0a94916ac - L3 gateway_decide_smsc # SMSC supplied:[dev] configured:[] decided smsc:[dev]
    • 2016-07-18 17:04:01 PID578d0a94916ac - L3 recvsms_process # feature:sms_custom datetime:2016-07-18 17:03:38 sender:629876543210 receiver:1234 keyword:T message:66 raw:T 66 smsc:dev

see this:

try to check your webserver’s log, see if playSMS hit the url

anton

Anton many thanks for the answer.

are the items in red something I should change to?

I have already updated to v1.4.

no its not.

just for test, can you check the checkbox on Make return as reply option in SMS custom and then do the test again, get the log and paste again

anton

debug1.txt (8.6 KB)

10.18.214.25 10.18.214.39 2016-07-19 16:09:29 PID578e50b9613ce admin L3 recvsms # isrecvsmsd:1 dt:2016-07-19 16:07:23 sender:629876543210 m:T 77 receiver:1234 smsc:dev
10.18.214.25 10.18.214.39 2016-07-19 16:09:29 PID578e50b9613ce admin L3 dev__incoming # Array ( [0] => Sender ID: 629876543210 [1] => Receiver number: 1234 [2] => Sent: 2016-07-19 16:07:23 [3] => Message: T 77 )

    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 recvsmsd # id:241 dt:2016-07-19 16:07:23 sender:629876543210 m:T 77 receiver:1234 smsc:dev
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 recvsms_process # dt:2016-07-19 16:07:23 sender:629876543210 m:T 77 receiver:1234 smsc:dev
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 gateway_decide_smsc # SMSC supplied:[dev] configured: decided smsc:[dev]
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 sms_custom_handle # returns:[ ]
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L2 sendsms # start uid:1 sender_id:[6970397151] smsc:[dev]
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 sendsms # maxlen:452 footerlen:7 footer:[ @admin] msglen:412 message:[ ]
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L2 sendsms_queue_create # saving queue_code:64302fbd343a9c9fc10737d52a3365cd src:6970397151 scheduled:2016-07-19 16:09:30
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L2 sendsms_queue_create # saved queue_code:64302fbd343a9c9fc10737d52a3365cd id:53
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 sendsms_manipulate_prefix # before prefix manipulation:[629876543210]
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 sendsms_manipulate_prefix # after prefix manipulation:[629876543210]
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 simplerate_hook_rate_getbyprefix # rate not found to:629876543210 default_rate:0
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 simplerate_hook_rate_getcharges # uid:1 u:admin len:419 unicode:0 to:629876543210 enable_credit_unicode:0 count:3 rate: charge:0
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L2 sendsms # dst_count:1 sms_count:3 total_charges:0
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L2 sendsms_queue_push # saving queue_code:64302fbd343a9c9fc10737d52a3365cd dst:629876543210
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L2 sendsms_queue_push # saved queue_code:64302fbd343a9c9fc10737d52a3365cd smslog_id:53
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L2 sendsms # end queue_code:64302fbd343a9c9fc10737d52a3365cd queue_count:1 sms_count:3 failed_queue:0 failed_sms:0
    • 2016-07-19 16:09:30 PID578d130ee08ad admin L3 recvsms_process # feature:sms_custom datetime:2016-07-19 16:07:23 sender:629876543210 receiver:1234 keyword:T message:77 raw:T 77 smsc:dev
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 sendsmsd # start processing queue_code:64302fbd343a9c9fc10737d52a3365cd chunk:0 queue_count:1 sms_count:3 scheduled:2016-07-19 16:09:30 uid:1 gpid:0 sender_id:6970397151
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 sendsmsd # sending queue_code:64302fbd343a9c9fc10737d52a3365cd smslog_id:53 to:629876543210 sms_count:3 counter:1
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 sendsms_intercept # msgtemplate modified sms_sender:[6970397151] sms_footer:[@admin] sms_to:[629876543210] sms_msg:[ ] uid:[1] gpid:[0] sms_type:[text] unicode:[0] queue_code:[64302fbd343a9c9fc10737d52a3365cd] smsc:[dev]
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 outgoing_hook_sendsms_intercept # using supplied smsc smsc:[dev] uid:1 from:6970397151 to:629876543210
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 sendsms_intercept # outgoing modified sms_sender:[6970397151] sms_footer:[@admin] sms_to:[629876543210] sms_msg:[ ] uid:[1] gpid:[0] sms_type:[text] unicode:[0] queue_code:[64302fbd343a9c9fc10737d52a3365cd] smsc:[dev]
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 sendsms_process # start
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 simplerate_hook_rate_getbyprefix # rate not found to:629876543210 default_rate:0
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 simplerate_hook_rate_getcharges # uid:1 u:admin len:419 unicode:0 to:629876543210 enable_credit_unicode:0 count:3 rate: charge:0
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 simplerate_hook_rate_cansend # allowed user uid:1 sms_to:629876543210 adhoc_credit:9999999999.999 count:3 rate: charge:0 adhoc_balance:9999999999.999
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 sendsms # saving smslog_id:53 u:1 parent_uid:0 g:0 gw:dev smsc:dev s:6970397151 d:629876543210 type:text unicode:0 status:0
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 sendsms_process # saved smslog_id:53 id:53
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 sendsms # final smslog_id:53 gw:dev smsc:dev message: @admin len:441
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 dev_hook_sendsms # enter smsc:dev smslog_id:53 uid:1 to:629876543210
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 dlr # isdlrd:1 smslog_id:53 p_status:3 uid:1
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 simplerate_hook_rate_deduct # enter smslog_id:53
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 simplerate_hook_rate_getbyprefix # rate not found to:629876543210 default_rate:0
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 simplerate_hook_rate_getcharges # uid:1 u:admin len:419 unicode:0 to:629876543210 enable_credit_unicode:0 count:3 rate: charge:0
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 simplebilling_hook_billing_post # saving smslog_id:53 rate: count:3 charge:0
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 simplebilling_hook_billing_post # saved smslog_id:53 id:52
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L3 simplerate_hook_rate_deduct # deduct successful uid:1 parent_uid:0 smslog_id:53
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 sendsms_process # end
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 sendsmsd # result queue_code:64302fbd343a9c9fc10737d52a3365cd to:629876543210 flag:1 smslog_id:53
    • 2016-07-19 16:09:31 PID578e50bb195d6 - L2 sendsmsd # finish processing queue_code:64302fbd343a9c9fc10737d52a3365cd uid:1 sender_id:6970397151 queue_count:1 sms_count:3
    • 2016-07-19 16:09:32 PID578d130ed30fe - L3 dlrd # id:90 smslog_id:53 p_status:3 uid:1
    • 2016-07-19 16:09:32 PID578d130ed30fe - L2 simplebilling__finalize # saving smslog_id:53
    • 2016-07-19 16:09:32 PID578d130ed30fe - L2 simplebilling__finalize # saved smslog_id:53

It was accessing handler.php and the script was returning something but its not printable by logger

So SMS custom worked, it only didnt understand what was being returned

Anton

Anton thank u

Is the custom URL processed via curl?

It really does not make sense this to run via browser to show as correctly executed but no result.

Does is matter is takes time to execute even through browser

Thanks
For your sharing

Not using curl, http post using file_get_content()

Anton

thanks Anton, do you see any reason while it will run via browser (delayed) and not via SMS Custom?

How long the delay ?

Anton

it is about 10 - 15 secs

ok, let see, try to add timeout option:

example:

		$opts = array(
			'http' => array(
				'method' => 'POST',
				'header' => "Content-type: application/x-www-form-urlencoded\r\n",
				'content' => $parsed_url['query'],
				'timeout' => 60
			) 
		);

anton

So the delay will be once posted yes?

'timeout' => 60 did not seem to have worked 

<a class="attachment" href="//cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/free1/uploads/playsms/original/1X/0fb2d22bd75a5230d2c3b813c6f5869e809c6fed.txt">debug9.txt</a> (1.1 KB)

.18.214.25 10.18.214.39 2016-07-20 22:02:05 PID578ff4dd055e9 admin L3 recvsms # isrecvsmsd:1 dt:2016-07-20 21:42:36 sender:629876543210 m:T 77 receiver:1234 smsc:dev
10.18.214.25 10.18.214.39 2016-07-20 22:02:05 PID578ff4dd055e9 admin L3 dev__incoming # Array (     [0] => Sender ID: 629876543210     [1] => Receiver number: 1234     [2] => Sent: 2016-07-20 21:42:36     [3] => Message: T 77 )
- - 2016-07-20 22:02:06 PID578ff4c63a4d3 - L3 recvsmsd # id:367 dt:2016-07-20 21:42:36 sender:629876543210 m:T 77 receiver:1234 smsc:dev
- - 2016-07-20 22:02:06 PID578ff4c63a4d3 - L3 recvsms_process # dt:2016-07-20 21:42:36 sender:629876543210 m:T 77 receiver:1234 smsc:dev
- - 2016-07-20 22:02:06 PID578ff4c63a4d3 - L3 gateway_decide_smsc # SMSC supplied:[dev] configured:[] decided smsc:[dev]
- - 2016-07-20 22:02:06 PID578ff4c63a4d3 - L3 sms_custom_handle # custom_url:[http://10.18.214.39/handler.php?param=77]
- - 2016-07-20 22:02:06 PID578ff4c63a4d3 - L3 sms_custom_handle # returns empty
- - 2016-07-20 22:02:06 PID578ff4c63a4d3 - L3 recvsms_process # feature:sms_custom datetime:2016-07-20 21:42:36 sender:629876543210 receiver:1234 keyword:T message:77 raw:T 77 smsc:dev

shows that fn.php does not seem to run for below part

        $parsed_url = parse_url($custom_url);
        
        $opts = array(
            'http' => array(
                'method' => 'POST',
                'header' => "Content-type: application/x-www-form-urlencoded\r\n",
                'content' => $parsed_url['query'] 
            ) 
        );
        
        $context = stream_context_create($opts);
        
        $server_url = explode('?', $custom_url);

That is how to do http post with file_get_contents()

Test your script with http post

Anton

Thank you, how do you test a script via http post?

Googling reveals one of them:

Im sure theres other way

Anton

so you suggest this section of fn.php changed somehow!?

$opts = array(
			'http' => array(
				'method' => 'POST',
				'header' => "Content-type: application/x-www-form-urlencoded\r\n",
				'content' => $parsed_url['query'],
				'timeout' => 60
			) 
		);