Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 用Arduino Yun发布请求_C_Arduino_Arduino Yun_Pushbullet - Fatal编程技术网

C 用Arduino Yun发布请求

C 用Arduino Yun发布请求,c,arduino,arduino-yun,pushbullet,C,Arduino,Arduino Yun,Pushbullet,以下POST通过终端的cURL工作: curl --header 'Authorization: Bearer <access token here>' --header 'Content-Type: application/json' -X POST https://api.pushbullet.com/v2/pushes --data-binary '{"type": "note", "title": "Note Title", "body": "Note Body"}'

以下POST通过终端的cURL工作:

curl
--header 'Authorization: Bearer <access token here>' 
--header 'Content-Type: application/json' 
-X POST https://api.pushbullet.com/v2/pushes 
--data-binary '{"type": "note", "title": "Note Title", "body": "Note Body"}'
curl
--标题“授权:持票人”
--标题“内容类型:应用程序/json”
-X柱https://api.pushbullet.com/v2/pushes 
--数据二进制“{”类型“:”注释“,”标题“:”注释标题“,”正文“:”注释正文“}”
然而,我一直无法在ArduinoIDE中复制这一点(在C中)。我想我可以使用HTTPClient对象,但是我在文档中只看到GET的方法,而不是POST

我将非常感谢任何朝着正确方向的点头。

我将尝试以下方法:

HttpClient client;
client.setHeader("Authorization: Bearer <access token here>");
client.addHeader();
client.setHeader("Content-Type: application/json");
client.addHeader();
client.post("https://api.pushbullet.com/v2/pushes", "{\"type\": \"note\", \"title\": \"Note Title\", \"body\": \"Note Body\"}"
HttpClient;
client.setHeader(“授权:承载人,它..

在questo modo funziona:-):


桥库只支持GET请求,但是您可以使用Process类来卷曲POST请求

这些文章解释了如何使用Process类分别将数据发送到ThingSpeak和Carriots api,但是您应该能够使用相同的技术访问您想要的任何api

希望这有帮助…我也会尝试一下,并跟进结果


如果您的端点是httpS,在调用
post()
get()
之前,请记住调用
client.noCheckSSL();

这将使库向curl添加一个
-K
标志,从而忽略安全ssl证书等

这一个也是没有文件的


您是否有此文档的链接?帖子是非常标准的功能。欢迎使用Stack Overflow!Stack Overflow是一个讲英语的网站,因此它要求所有问题和答案都是英语。如果可以,请将您的答案翻译成英语。如果需要,我们可以帮助编辑以提高英语水平。您的代码可能会工作,但向OP正确解释是回答问题的一个重要部分。我可以确认这在Yun上有效。但是,您不需要使用client.addHeader()函数,因为它是私有的,并且在需要时由类自动调用。知道如何使用八位字节流数据来实现这一点吗?就像图像一样,是否需要发布每个字节?可以尝试找到一些shell转义序列并对数据进行适当编码(查看.Or,更好的选择是使用将数据写入文件,然后执行类似于
client.post()https://api.pushbullet.com/v2/pushes“,“@/path/to/file.png”)
,利用数据作为
curl
--data
参数传入的事实。不用说,这可能不是它的预期用途。。。
Process avviso;


if (!avviso.running())
  {
    avviso.begin("curl");
    avviso.addParameter("-k");
    avviso.addParameter("-H");
    avviso.addParameter("Authorization: Bearer v1EhAXIVEhms05l97PTHkQFRNWiK5q6L6fujzny9qxWvc");
    avviso.addParameter("-X");
    avviso.addParameter("POST");
    avviso.addParameter("https://api.pushbullet.com/v2/pushes");
    avviso.addParameter("-H");
    avviso.addParameter("Content-Type:application/json");
    avviso.addParameter("--data-binary");
    String titolo = "Arduino";
    avviso.addParameter("{\"type\": \"note\", \"title\": \""+titolo+ "\", \"body\": \"Note Body\"}");
    avviso.run(); 
  }