- Download and install the POSTman app
- Create a 46elks account
- A live server to run PHP on. You can send a SMS with your name to +46766865445 and you get an account on our workshop server
Why and when use APIs?
- Open up access to data
- Automation - access to systems
- Layer on top of complexity
You’ll encounter terminology and abbreviations that make no sense, and that’s ok!
- status codes
- GET & POST
- Live server
- format (json, xml, other)
- Open data
Why & when APIs?
The address. You have a home address. The API has its home address on the internet.
Just like websites. Example:
- GET Ask for data.
- POST Send in data. Trigger an event.
- Contact those providing the API!
- Stackoverflow to the rescue!
- People! Go to meetups, hackathons, explore forums... when you have friends you can help them out, and they can help you out!
- You can also search for API reference manual, API documentation, API docs or API manual to find more information as well.
- 200 All is well.
- 404 Can't find what you're looking for!
- 20x OK!
- 30x Somewhere else!
- 40x You're not doing it right.
Check the documentation/manual/instruction. Ask for help!
Example: https://46elks.com/thispagedoesnotexist - 404.
- 50x We made a mistake! Perhaps you might want to let us know! Or try again later!
- http cat is a good place to find your current status code
- API key
- Basic auth
Send SMS with PHP
Log in to the server
- Log on to the live server by opening a Command line window. Switch out
usernamefor the username you got in your SMS
- Log in with the password you got in your SMS
- To start the server you run this but switch out
500to the port you have been assigned in your SMS
- Now you can reach the server on this URL:en
500to your own port
- When you want to switch off the server you simply run
ctrl + C
Write the code
- Create a new file by running
Ifor Insert mode which allows you to write in Vim
- Now for the code itself, copy and paste this in your file
- Change the username and password to your API credentials, you find them here
- Change the
messageparameters to your own
- To save the file press
ESC + :wq
- Start the server and access the url
Want to try more languages?
You can find more examples in many different programming languages available on GitHub or our tutorials here