bureus / MMM-Vasttrafik-PublicTransport

Initial commit
9 stars 6 forks source link

Getting endpoints #6

Closed EhsanMomeni81 closed 5 years ago

EhsanMomeni81 commented 5 years ago

How do I get endpoint? I write Trollhättan Station, but I don't get any response.

Req URL https://api.vasttrafik.se/bin/rest.exe/v2/location.name?input=Trollh%C3%A4ttan%20Station

response code 401

retroflex commented 5 years ago

Try using the location.nearbyStops in the Västtrafik's API console. I entered the coordinates for Trollhättan C (from Google maps) and found these:

StopLocation name="Trollhättan resecentrum, Trollhättan" id="9022014081800025" lat="58.287252" lon="12.296749" track="L" StopLocation name="Trollhättan resecentrum, Trollhättan" id="9022014081800022" lat="58.287684" lon="12.297900" track="B" StopLocation name="Trollhättan resecentrum, Trollhättan" id="9022014081800021" lat="58.287702" lon="12.298016" track="A" StopLocation name="Trollhättan resecentrum, Trollhättan" id="9022014081800023" lat="58.287261" lon="12.297998" track="C" StopLocation name="Trollhättan resecentrum, Trollhättan" id="9022014081800024" lat="58.287189" lon="12.298016" track="D" StopLocation name="Trollhättan resecentrum, Trollhättan" id="9022014081800020" lat="58.287459" lon="12.298394" track="X" StopLocation name="Trollhättan station, Trollhättan" id="9022014081600001" lat="58.287693" lon="12.298610" track="1" StopLocation name="Trollhättan station, Trollhättan" id="9022014081600023" lat="58.287306" lon="12.298655" track="X" StopLocation name="Trollhättan station, Trollhättan" id="9022014081600002" lat="58.287729" lon="12.298682" track="2" StopLocation name="Trollhättan resecentrum, Trollhättan" id="9021014081800000" lat="58.287126" lon="12.298673"

EhsanMomeni81 commented 5 years ago

Thank you so much. I hadn't thought about using Google Maps.

bureus commented 5 years ago

Hi, it worked for me directly from the portal. According to the response code it seems like you get 401, meaning unauthorized. This could happen if you are at the portal while the magic mirror module is running. Seems like the access token is refreshed every time the application fetches a new one. I have updated the readme file to state this more clearly. Glad that @retroflex could help you resolve it 👍