3. So you want to learn how to
code?
• Coding takes time, practice and
patience.
• Don’t give up, there’s always a solution.
• Think logically.
4. Hyper Text Transfer
Protocol• <protocol>://<subdomain><server><port:80><path>
• sacheen.plex.com:32400/web/index.html
• Request / Response
• Client initiate’s a request
• Server generates a response
• HTTP is stateless
• Server /Client does not keep record of the connection
6. Request/Response
• Each Request contains information:
• The HOST: www.google.com
• The COOKIES: This may contain a session that the server can use to
identify you - because http is stateless
• The CONTENT: what kind information you sending the server
• The METHOD that the server needs to perform,
GET,PUT,POST,DELETE
• There are other parameters sent to the server, but the above covers the
basics
8. Request/Response
• Each Response contains information:
• The STATUS: the code that determines the success or failure of a
request,
• 200, 500, 404, 503, 301, 302…etc
• The CONTENT: The data sent back by the server
• There is more information sent back, but the above is the the most
important
9. GET
• Get data from the server
POST
• Update/Create data on the server, most developers use POST as creation as well
PUT
• Create/Update data on the server
DELETE
• DELETE’s data from the server
HEAD
• Identical to GET except that the server MUST NOT return a message-body in the
response.
OPTIONS
• Represents a request for information about the communication options available on
the request/response chain identified
10. GET
• Request
• URL: https://www.afrihost.com/
• Content: none
• Response:
• CONTENT: the page you requested
• STATUS: 200
11. POST
• Request
• URL: https://www.afrihost.com/testimonial
• Content: name=bob&age=5&message=amazing site
• Response:
• CONTENT: some success page
• STATUS: 200
12. PUT
• Request
• URL: https://www.afrihost.com/testimonial
• Content: name=bob&age=5&message=amazing site
• Response:
• CONTENT: some success page
• STATUS: 200
13. DELETE
• Request
• URL: https://www.afrihost.com/testimonial/100
• Content: id=100 [the spec does not forbid or discourage it]
• Response:
• CONTENT: some delete success page
• STATUS: 200
17. Accessing data in PHP
• $_GET[“data”]; //somepage.com/?data=steve
• $_POST[“data”] somepage.com/some-path Content: data=steve
• parse_str(file_get_contents('php://input'), $put) put data is sent
via stdin $put[“data”]
19. Closing
• The request-response conversation is the fundamental process that
drives all communication on the web.
• Regardless of the language you use, the type of application you build
(web, mobile, JSON API) or the development philosophy you follow,
the end goal of an application is always to understand each request
and create and return the appropriate response
• KISS – KEEP IT SIMPLE STUPID – don’t over complicate things
• Do one thing and do it well