Skip to content

Commit 6a08f38

Browse files
committed
working version of feed create with manual requests
1 parent 0d75d6f commit 6a08f38

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

AdafruitIO_Feed.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,26 @@ bool AdafruitIO_Feed::save(double value, double lat, double lon, double ele, int
116116

117117
bool AdafruitIO_Feed::exists()
118118
{
119-
_io->_http->get(_feed_url);
119+
_io->_http->startRequest(_feed_url, HTTP_METHOD_GET);
120120
_io->_http->sendHeader("X-AIO-Key", _io->_key);
121121
int status = _io->_http->responseStatusCode();
122122
return status == 200;
123123
}
124124

125125
bool AdafruitIO_Feed::create()
126126
{
127+
String body = "name=";
128+
body += name;
127129

130+
_io->_http->startRequest(_create_url, HTTP_METHOD_POST);
131+
_io->_http->sendHeader(HTTP_HEADER_CONTENT_TYPE, "application/x-www-form-urlencoded");
132+
_io->_http->sendHeader(HTTP_HEADER_CONTENT_LENGTH, body.length());
133+
_io->_http->sendHeader("X-AIO-Key", _io->_key);
134+
_io->_http->endRequest();
135+
_io->_http->write((const byte*)body.c_str(), body.length());
136+
137+
int status = _io->_http->responseStatusCode();
138+
return status == 201;
128139
}
129140

130141
void AdafruitIO_Feed::setLocation(double lat, double lon, double ele)

0 commit comments

Comments
 (0)