These are my remote server credentials that I want to connect from my local device.
Server m12.cloudserver.com
User <myname>
Password <mypassword>
Port 19999
_ or
api_key 5678909876-009-00d
I want to use the WiFiClient client() API as shown, but where or how do I include the User credentials ? so that I can make a successful connection to the remote server from my device connected over Wifi.
Cut and paste from my Arduino code.
const int httpPort = 19999;
if (!client.connect("m12.cloudserver.com", httpPort)) {
Serial.println("connection failed");
return;
}
-
Read the API docs.gre_gor– gre_gor2017年05月10日 13:56:35 +00:00Commented May 10, 2017 at 13:56
1 Answer 1
WifiClient provides low level tcp connection. Your server seems to be implementing a REST API interface. Thus you need to construct HTTP headers (GET, POST, etc.) manually as a string. Then you can add your credentials. Before doing so, try to use your server, I mean call api's with the program named Postman
. Postman runs on Chrome browser. Postman
can compose such headers for you. Then you can insert them into your arduino code.