Description
You want to offer your users a way to see radio stations in their area. It should work automatically but also support an override, perhaps by entering a zipcode or geocoordinate.
Solution
This is such a common scenario that our APIs support it natively:
- In OPML: Browse local
- In OpenMedia: Browse local
To change location, you have several options:
- In OPML: Use search and specify a zipcode as the query text.
- In OPML: Use the
latlonparameter in conjunction with local browse to perform a proximity search. - In OpenMedia: Use getMetadata and specify an ID of “z” + zipcode
- In both: Pass a configured RadioTime account username to the browse local method; the service will use the location from the account.
Considerations
IP address location works well on the desktop or on connected devices with a fixed IP. It is not accurate on mobile networks, and it will not work at all if you proxy requests for your clients. In case of the latter, you may pass along the originating IP address in an HTTP X-Forwarded-For header:
GET /Browse.ashx?c=local HTTP/1.0
X-Forwarded-For: 192.168.1.1
....