我正在尝试在arduino上运行代码以使用推送通知-但我在那里有一个探查 所以我认为我应该尝试在C#上运行它-这样我就可以对其进行调试
这是arduino C中的代码
const Example = () => {
let node;
return (
<div>
<p ref={el => (node = el)}>hello world!</p>
{console.log(node)}
</div>
);
};
const rootElement = document.getElementById("root");
ReactDOM.render(<Example />, rootElement);
我的问题是- 这是C#中的代码:
String deviceId = "v12451BC5EA631A1";
const char* logServer = "api.pushingbox.com";
void sendNotification() {
WiFiClient client;
Serial.println("- connecting to pushing server: " + String(logServer));
if (client.connect(logServer, 80)) {
Serial.println("- succesfully connected");
Serial.println(deviceId);
String postStr = "devid=";
postStr += String(deviceId);
postStr += "&message_parameter=";
postStr += String("test");
postStr += "\r\n\r\n";
Serial.println("- sending data...");
client.print("POST /pushingbox HTTP/1.0\n");
client.print("Host: api.pushingbox.com\n");
client.print("Connection: close\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\r\n\r\n");
client.print(postStr);
Serial.println(postStr);
}
client.stop();
Serial.println("- stopping the client");
}
我得到的回应是 “ HTTP错误401” 但是当我看着 在pushbox仪表板中,我可以看到每次运行代码都获得了新的乐趣。 那为什么我会收到这个错误? 也是