Posting to Thingspeak
-
I searched the forums and internet and was surprised that I could not find examples of any Qt apps posting to Thingspeak. Did I miss some helpful examples somewhere?
--George
-
@GeorgeIoak Well, this is a REST API, you use it as any other REST API. Why do you need specific Qt example? Take a look at Qt networking and its examples: http://doc.qt.io/qt-5/qtnetwork-index.html
-
Thanks, I'm quite new to Qt and slowly learning so I was just looking for some examples as I hadn't done any networking tasks with Qt yet.
It looks as though I should use QNetworkAccessManager and then is it as simple as following this example:
QNetworkAccessManager *manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); manager->get(QNetworkRequest(QUrl("http://qt-project.org")));
Except perhaps replacing the get with post?
-
Yes, I got it working this afternoon. It seems to work with get. I haven't handled any of the replies or error checks but I found another example and together with this it's working.
-
It all depends on the endpoint you are calling and how it's implemented on the other hand. The documentation tells which one you should use.