I am trying to access strava's API on arduino esp8266. My http.GET() using the ESP8266HTTPClient.h header is returning -1 which means that it fails to connect at some point (HTTPC_ERROR_CONNECTION_REFUSED). I am able to access other sites but am just having trouble linking up to Strava. Here is Strava's api site
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>
const char* ssid = "**SSIDNAME**";
const char* password = "**PASSWORD**";
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(1000);
Serial.println("Connecting...");
}
}
void loop()
{
if (WiFi.status() == WL_CONNECTED)
{
Serial.println("Connected!");
HTTPClient http; //Object of class HTTPClient
http.begin("https://www.strava.com/athletes/**ATHLETENUMBER**", "**MY CLIENT SECRET**");
int httpCode = http.GET();
if (httpCode > 0)
{
const size_t bufferSize = JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(5) + JSON_OBJECT_SIZE(8) + 370;
DynamicJsonBuffer jsonBuffer(bufferSize);
JsonObject& root = jsonBuffer.parseObject(http.getString());
const char* miles = root["all_run_totals"];
Serial.print("Total miles:");
Serial.println(miles);
}
http.end(); //Close connection
}
delay(60000);
}