need a sample php code
I have API key of https://www.trafiklab.se/api/sl-reseplanerare-31
Now I need sample php code to get traffic and way points with this api. Please provide me a sample php code to use this api by curl or by any another method.
Now I need sample php code to get traffic and way points with this api. Please provide me a sample php code to use this api by curl or by any another method.
Följ inlägget
0
följare
https://api.sl.se/api2/TravelplannerV3_1/journeydetail.json?key=<My_Key>&lang=en&originCoordLat=59.329323&originCoordLong=18.068581&destCoordLat=59.339455&destCoordLong=18.013777&maxChange=3&lines=!19
We don't have complete examples, but we are currently working on an open-source SDK. The documentation is a bit lacking at the moment as it is still being worked on, but it might be useful to you: https://github.com/trafiklab/sl-php-sdk
The package can be installed using "composer require trafiklab/sl-php-sdk".
An example on how this is used can be found in our Google Assistant demo project: https://github.com/trafiklab/google-assistant-demo/blob/master/app/Http/Controllers/RoutePlanningController.php
These projects are available under the MPL-2 license. The exact terms can be found here: https://www.mozilla.org/en-US/MPL/2.0/
Please note that our SDKs don't offer all the functionality of the APIs, only basic features are exposed. If you need features that are not implemented in the SDK, you can either fork our SDK and develop it further, or you can use the API as an example and write your own code based on it.
Feel free to reach out if you have further questions.
Greetings,
Bert
In the trip api https://api.sl.se/api2/TravelplannerV3_1/trip.<FORMAT>?key=<DIN API KEY> & parameters
which parameter (keys) is belong to number of trains and buses in one Leg. Please see attached screenshot.
Every leg contains "product" details, for example:
"Product": {
"name": "TUNNELBANA 13",
"num": "20678",
"line": "13",
"catOut": "METRO ",
"catIn": "MET",
"catCode": "1",
"catOutS": "MET",
"catOutL": "TUNNELBANA ",
"operatorCode": "SL",
"operator": "Storstockholms Lokaltrafik",
"admin": "106013"
},
Using this information, you can get a list of all vehicles and vehicle types used in a trip. To be clear, example you pointed at in your screenshot is not how much busses are used, but for example metro line 11, tram line 21, boat 1473, ... which can all be found in the product data.
Regards,
Bert
Thank you Sir, It helped me.
Sir, I want to ask one more question that is
How can I determine the color of Bus and color of subway.
Which is the key in api to find the color of the bus and subway.
{
"LineNumber": "19",
"LineDesignation": "19",
"DefaultTransportMode": "tunnelbanans gröna linje",
"DefaultTransportModeCode": "METRO",
"LastModifiedUtcDateTime": "2007-08-24 00:00:00.000",
"ExistsFromDate": "2007-08-24 00:00:00.000"
},
{
"LineNumber": "19",
"LineDesignation": "19",
"DefaultTransportMode": "Waxholmsbolagets",
"DefaultTransportModeCode": "SHIP",
"LastModifiedUtcDateTime": "2009-09-02 00:00:00.000",
"ExistsFromDate": "2009-09-02 00:00:00.000"
},
{
"LineNumber": "199",
"LineDesignation": "199",
"DefaultTransportMode": "",
"DefaultTransportModeCode": "BUS",
"LastModifiedUtcDateTime": "2007-08-24 00:00:00.000",
"ExistsFromDate": "2007-08-24 00:00:00.000"
},
{
"LineNumber": "2",
"LineDesignation": "2",
"DefaultTransportMode": "blåbuss",
"DefaultTransportModeCode": "BUS",
"LastModifiedUtcDateTime": "2007-08-24 00:00:00.000",
"ExistsFromDate": "2007-08-24 00:00:00.000"
},
{
"LineNumber": "22",
"LineDesignation": "22",
"DefaultTransportMode": "Tvärbanan",
"DefaultTransportModeCode": "TRAM",
"LastModifiedUtcDateTime": "2007-08-24 00:00:00.000",
"ExistsFromDate": "2007-08-24 00:00:00.000"
},
Red busses have no special naming, blue busses are indicated by blåbuss. The metro lines are linked to their line color/line name, and trams are linked to the name of their line as well. I hope this solves your question.
Regards,
Bert
I am getting nothing. It is showing error, {"StatusCode":1002,"Message":"Key is invalid"}
How can I get colors from array ?
I am using following url
https://api.sl.se/api2/TravelplannerV3_1/trip.json?key=<DIN API KEY> & parameters.
Please help me to get colors of the vehicles.
Regards,
Bert