Send requests to the following URL:
The parts between
% should be replaced with the following:
%service-version%: the version of the service
%service-name%: the name of the service
%token%: a token which gives you access to the web service
A JSONP request is sent using HTTP GET, with these URL parameters:
Keep in mind that most browsers have a limit on URL length, passing large amounts of data to the web service may not be possible with this protocol (it is not a problem for the response).
The server sends back a JSON encoded object containing these keys:
If you have provided the callback parameter in the request, your callback function is called with the response.
The following code fetches all the routes (private ones included) you have marked as favourite. Note that there is no error handling in this example.
// Start session. Acquire the token that is needed for the subsequent web service calls. $params = array( '<key>' ); $url = 'http://api.routeyou.com/2.0/json/Session?id=1&method=start¶ms=' . json_encode($params); $response = json_decode(file_get_contents($url), true); $token = $response['result']; // Log in. $params = array( '<email>', '<password>' ); $url = 'http://api.routeyou.com/1.1/json/Authentication/' . $token . '?id=1&method=loginWithEmail¶ms=' . json_encode($params); $response = json_decode(file_get_contents($url), true); $user = $response['result']; // Fetch favourite routes. // When parameter permission.readable is omitted, only public routes are returned. $params = array( array( 'favourite.user.id' => $user['id'], 'permission.readable' => true ) ); $url = 'http://api.routeyou.com/2.0/json/Route/' . $token . '?id=1&method=search¶ms=' . json_encode($params); $response = json_decode(file_get_contents($url), true); $favourites = $response['result']; var_dump($favourites);
© 2006-2018 RouteYou - www.routeyou.com