User Tools

Site Tools


ios-labs-s14:intermediate-api

API

Communicating with a server may involve sending that server information.

Generally, communicating with servers is accomplished over the open internet using HTTP requests.

There are two broad ways of accomplishing this: embedding information as a query string within the URL being visited or including information in the body of the HTTP request in the form of JSON or XML.

This page covers the former.

A '?' after a URL signifies the start of the list of arguments as key/value pairs. Example by googling “hello” (note: in the top bar of google chrome; if done from google.com returns something different):

https://www.google.com/search?q=hello&rlz=1C1CHMO_enUS567US567&oq=hello&aqs=chrome..69i57j69i59j69i60j69i59l2j0.1151j0j9&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8

Note the question mark. Here is part of the string following the question mark:

...?q=hello&rlz=1C1CHMO_enUS567US567&oq=hello&aqs=chrome..69i57j69i60l2j69i59l2j69i60.554j0j8...

A key (or variable) is denoted by the text to the left of an equals sign, while its value sits on the right. The same snippet with whitespace added:

?q=hello& rlz=1C1CHMO_enUS567US567& oq=hello& aqs=chrome..69i57j69i60l2j69i59l2j69i60.554j0j8

Keys: q, rlz, oq, aqs Values: hello, 1C1CHMO_enUS567US567, hello, etc

Ampersands are used to add on key/value pairs to the URL.

In order to use functionality like this, you must have explicit understanding of how the server processes values it receives, this is most easily accomplished by writing both the server and the app, but is more commonly done by ensuring the backend developer keeps an open line of communication with the frontend developer and doesn't drastically change things.

ios-labs-s14/intermediate-api.txt · Last modified: 2014/02/23 22:16 by mbarboi