Skip to content

Commit 1516e74

Browse files
committed
Now working
1 parent a17d89e commit 1516e74

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/YoutubeApi.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,23 @@ bool YoutubeApi::getChannelStatistics(String channelId){
8181

8282
bool YoutubeApi::getChannelStatistics(char *channelId){
8383
char command[150] = YTAPI_CHANNEL_ENDPOINT;
84-
strcat(command, "?part=statistics&id=%s");
85-
sprintf(command, command, channelId);
86-
strcat(command, "&key=%s");
87-
sprintf(command, command, _apiKey);
84+
char params[120];
85+
sprintf(params, "?part=statistics&id=%s&key=%s", channelId, _apiKey);
86+
strcat(command, params);
8887

8988
if (_debug)
9089
{
9190
Serial.println(command);
9291
}
9392

94-
bool hasError = true;
93+
bool wasSuccessful = false;
9594

9695
// Get from https://arduinojson.org/v6/assistant/
9796
const size_t bufferSize = JSON_ARRAY_SIZE(1)
9897
+ JSON_OBJECT_SIZE(2)
9998
+ 2*JSON_OBJECT_SIZE(4)
100-
+ JSON_OBJECT_SIZE(5);
99+
+ JSON_OBJECT_SIZE(5)
100+
+ 330;
101101

102102
int httpStatus = sendGetToYoutube(command);
103103

@@ -110,7 +110,7 @@ bool YoutubeApi::getChannelStatistics(char *channelId){
110110
DeserializationError error = deserializeJson(doc, *client);
111111
if (!error)
112112
{
113-
hasError = false;
113+
wasSuccessful = true;
114114

115115
JsonObject itemStatistics = doc["items"][0]["statistics"];
116116

@@ -131,7 +131,7 @@ bool YoutubeApi::getChannelStatistics(char *channelId){
131131
}
132132
closeClient();
133133

134-
return hasError;
134+
return wasSuccessful;
135135
}
136136

137137
void YoutubeApi::skipHeaders()

0 commit comments

Comments
 (0)