Restful web services using slim and PHP

I have created a restful webservices using slim framework and PHP. I have created APIs for simulation atm machine.  In my case, ATM machine is PC and PC have uniquie name and password. The PC information is save in a file in jSOn format (serviceconfig.txt);

{“Machines”:[{“name”:”PC1″,”password”:”test”}]}

If you want to add another machine, add it in the above jSon..

And user information is saved in file(2007_1.txt);

{“User”:[{“name”:”Jawad”,”user_id”:”2007″,”pin”:1234,”balance”:49900}]}

If you want to create another user ,you will create another file having name userid_1.txt.

And its mini statement info is a save in userid_2, which is automatically created.

Following work of atm is simulated;

  • Enter a 4 digit user id here to simulate a card scan.

Its is handled with post method with name and password.

http://localhost/atm-services/login

  • Enter PIN screen

It is also handled with post method with name, password, userId and pin.

http://localhost/atm-services/pin

  • Balance check

It is handled with get method.

http://localhost/atm-services/balance/PC1/test/2007/1234

  • Cash withdrawal

It is also handled with post method with name, password, userId, pin and amount to withdraw.

http://localhost/atm-services/cashwithdraw

 

  • PIN change

It is also handled with post method with name, password, userId, pin and changepin.

  • Mini statement

It is handled with get method.

http://localhost/atm-services/ministatement/PC1/test/2007/1234

Code

Advertisements