https://github.com/dougblackjr/septabot
This is going to be a very simple implementation of the SEPTA stats API to determine which train heading outbound is coming next.
We'll learn:
- Some high level programming concepts (conditionals, arrays, loops)
- Very basic PHP stuff
- Pseudocode
- How to call an API and parse the data
- How to Dump and Die! #clickbait
- How to never trust user input
This won't necessarily be best practices, but just enough to get your hands dirty in PHP. It'll be a very bare bones minimum viable product (just enough to get the job done).
You can see a bit of what we'll do in index.php
!
- A computer
- A notebook
- A pen
- Download the code from here: https://github.com/dougblackjr/septabot/archive/master.zip
- Unzip the file!
- Download and install Postman: https://www.getpostman.com/docs/postman/launching_postman/installation_and_updates
- Open your Terminal. We'll do some of our work here
- Type in terminal:
cd septabot/example
- Start a PHP server by typing in terminal:
php -S localhost
- Open Postman and do a New Request with the following parameters:
- URL:
http://localhost/
- Request Type: POST (You'll see Get next to the URL bar)
- Body:
- token: 12345
- command: train
- text: Warminster (or Wil or snerd)
- URL:
- Play around! Enjoy!