Community discussions

MikroTik App
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

How to get details after a certain text in sms?

Tue Jan 17, 2023 5:17 pm

Im working now for a project called Cashless transaction using sms , wherein when someone paid there bill, mikrotik will automatically look for its account number and Reference number, the problem is I dont know how to code the specific string on the sms.

Ex. Text SMS

You have received PHP 1.00 of GCash from JO**E J* P. 09537424754 w/ MSG: 2021001. Your new balance is PHP 24.00. Ref. No. 6007722478141.

I do like to get the "MSG: 2021001" and also the "Ref No. XXXXXXXXXXX" which is randomly generated. by the user.

I did some research on PHP language, but i i could make it happen on ROS ,

Here's the sample PHP Code

<!DOCTYPE html>
<html>
<body>

<?php
$string="admin wrote a new post, FIRE 2 days, 2 hours ago";
$result=preg_split('/post,/',$string);
if(count($result)>1){
$result_split=explode(' ',$result[1]);
print_r($result_split[1]);
}
?>

</body>
</html>


Please do help, thankyou
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: How to get details after a certain text in sms?

Wed Jan 18, 2023 6:47 pm

anyone to help ?
 
zainarbani
Frequent Visitor
Frequent Visitor
Posts: 54
Joined: Thu Jul 22, 2021 9:42 am
Location: Pati, Indonesia

Re: How to get details after a certain text in sms?

Fri Jan 20, 2023 7:24 pm

I dont get ur questions actually,
something like this?
:local smss "You have received PHP 1.00 of GCash from JO**E J* P. 09537424754 w/ MSG: 2021001. Your new balanc
e is PHP 24.00. Ref. No. 6007722478141.";

:log warning [:pick $smss [:find $smss "MSG:"] [:find $smss " Your"]];
:log warning [:pick $smss [:find $smss "Ref."] [:len $smss]];

 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How to get details after a certain text in sms?

Sat Jan 21, 2023 2:24 am

Not well done...
{
:local smss "You have .... 37424754 w/ MSG: 2021001. Your new ... Ref. No. 6007722478141.";

# Only the numbers:
:put [:pick $smss ([:find $smss "MSG: "] + 5) [:find $smss ". Your new"]]
:put [:pick $smss ([:find $smss "Ref. No. "] + 9) ([:len $smss] - 1)]

# also with test before
:put [:pick $smss [:find $smss "MSG: "] [:find $smss ". Your new"]]
:put [:pick $smss [:find $smss "Ref. No. "] ([:len $smss] - 1)]
}
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: How to get details after a certain text in sms?

Thu Jan 26, 2023 2:37 pm

Thankyou sir Rextended , so much appreciated, ive been working this for wk now, thankyou so much!
Last edited by akira463 on Thu Jan 26, 2023 3:41 pm, edited 1 time in total.
 
User avatar
akira463
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jan 11, 2018 12:30 pm
Location: Ph

Re: How to get details after a certain text in sms?

Thu Jan 26, 2023 2:38 pm

Also thankyou sir zainarbani , so much appreciated too!

Who is online

Users browsing this forum: No registered users and 20 guests