Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension.conf
- [subBalance]
- exten=>751,1,Answer()
- same=>n(auth),Set(ID=${ODBC_AUTHUSER(${EXTEN}, 1234)});send the exten & PIN of this caller and get their ID
- same=>n,NoOp(the ID is ${ID})
- same=>n,GotoIf($[${ISNULL(${ID})}]?auth:getbalance);request to enter pin again else get their current balance
- same=>n(getbalance),Set(BALANCE=${ODBC_BALANCE(${ID})});send the ID of this user and get their balance
- same=>n,SayNumber(${BALANCE});tell user their current balance
- same=>n,Hangup()
- //func_odbc.conf
- [AUTHUSER]
- dsn=asterisk
- readsql=SELECT id FROM `user_accounts` where exten=${ARG1} and pin=${ARG2}
- [BALANCE]
- dsn=asterisk
- readsql=SELECT balance FROM `user_accounts` where id= ${ARG1}
- //mysql result
- SQL result
- Host: localhost
- Database: asterisk
- Generation Time: Oct 22, 2012 at 02:00 PM
- Generated by: phpMyAdmin 3.5.2.2 / MySQL 5.5.25-log
- SQL query: SELECT * FROM `user_accounts` LIMIT 0, 30 ;
- Rows: 1
- id exten pin balance
- 1 50 1234 10000
- //asterisk cli
- Executing [751@local:2] Set("SIP/50-00000003", "ID=") in new stack
- -- Executing [751@local:3] NoOp("SIP/50-00000003", "the ID is ") in new stack
- -- Executing [751@local:4] GotoIf("SIP/50-00000003", "1?auth:getbalance") in new stack
- -- Goto (local,751,2)
- -- Executing [751@local:2] Set("SIP/50-00000003", "ID=") in new stack
- -- Executing [751@local:3] NoOp("SIP/50-00000003", "the ID is ") in new stack
- -- Executing [751@local:4] GotoIf("SIP/50-00000003", "1?auth:getbalance") in new stack
- -- Goto (local,751,2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement