Created
January 27, 2020 19:29
-
-
Save fqborges/8ca844cbc5ac316809c6b46a562f7a41 to your computer and use it in GitHub Desktop.
Exemplo de acesso api mobiltracker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Net.Http; | |
| using System.Threading.Tasks; | |
| namespace api | |
| { | |
| class Program | |
| { | |
| static async Task Main(string[] args) | |
| { | |
| const string API_KEY = "Solicitar via atendimento"; | |
| var url = "https://api.mobiltracker.com.br/trackers/233763/history/2019-01-27T000000Z"; | |
| var client = new HttpClient(); | |
| // CHAVE DE API VIA QUERY STRING | |
| url = url + $"?apiKey={API_KEY}"; | |
| // OU VIA HEADER | |
| // client.DefaultRequestHeaders.Add("Authorization", $"AuthDevice {API_KEY}"); | |
| var response = await client.GetAsync(url); | |
| var content = await response.Content.ReadAsStringAsync(); | |
| Console.WriteLine(content); | |
| // [ | |
| // {"latitude":-23.97782,"longitude":-48.877715,"speed":0.0,"timestamp":"2020-01-27T19:20:00Z"}, | |
| // {"latitude":-23.97790,"longitude":-48.877777,"speed":0.0,"timestamp":"2020-01-27T19:21:00Z","endTimestamp":"2020-01-27T19:25:00Z"}, | |
| // ... | |
| // ] | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment