Location resource
From IW Challenge - Developer
Location resource can be used to query the location of the device containing the SIM with MSISDN the User registered.
Contents |
Restrictions
- It is only possible to locate your own registered MSISDN.
- Works only with Sonera SIMs at the moment.
- serviceKey and userKey must match the same developer
Resource
| Resource location: http://api.medialab.sonera.fi/iw/rest/location |
| serviceKey : service key of the service accessing the resource |
| userKey : user key of the user accessing the resource |
Related resources
XML schema
http://api.medialab.sonera.fi/iw/schema/Location
XML format
Content-type: application/xml
<location> <msisdn>35811111111</msisdn> <cell> <lat>60.316391</lat> <lon>20.994058</lon> <mcc>244</mcc> <mnc>91</mnc> <lac>0</lac> <cellid>10038</cellid> <name>Brändö</name> </cell> </location>
JSON format
JSON reply is provided if HTTP header key Accept is set to application/json
Content-type: application/json
- Example
{"location":{ "msisdn" : "358111111111", "cell" : { "lat" : "60.316391", "lon" : "20.994058", "mcc" : "244", "mnc" : "91", "lac" : "0", "cellid" : "10038", "name" : "Brändö" } }}
GET (Read)
| Resource location: http://api.medialab.sonera.fi/iw/rest/location |
Read Location resource. Returns the Location resource as a XML or JSON document. Default format is XML. Result is in JSON format if request header "Accept" is set to "application/json".
Response codes
200 |
Resource data in the body |
401 |
Authorization failed. ServiceKey and userKey paramaeters must match the same Developer |
403 |
Positioning is not allowed. This status will be returned if the user has not (yet) replied to the initial authorization SMS allowing positioning. |
Examples
Assuming the user has allowed positioning, we can fetch the position of the mobile device with a HTTP GET:
Example curl request:
$ curl -X GET -i "http://api.medialab.sonera.fi/iw/rest/location?userKey=your-user-key&serviceKey=your-service-key"
HTTP/1.1 200 OK Date: Tue, 31 Mar 2009 13:10:12 GMT Server: Apache/2.2 Content-Length: 431 Content-Type: application/xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <location> <msisdn>3581234567890</msisdn> <state>Idle</state> <cell> <lat>61.492494</lat> <lon>23.773164</lon> <mcc>244</mcc> <mnc>91</mnc> <lac>5002</lac> <cellid>54590</cellid> <name>Tampere</name> </cell> </location>