如何在xcode中使用curl和c++的rest API

how to use rest api with curl and c++ in xcode

本文关键字:c++ rest API curl xcode      更新时间:2023-10-16

我试图使用REST将简单数据POST到Parse服务器,但不能这样做,以下是代码

#include<curl/curl.h>
curl -X POST 
-H "X-Parse-Application-Id: xxxxxxxxxx" 
-H "X-Parse-REST-API-Key: xxxxxxxxxxxx" 
-H "Content-Type: application/json" 
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' 
https://api.parse.com/1/classes/GameScore

这里的X是什么?我们需要定义x吗?需要使用哪些连接设置才能成功发布数据?哪里是返回对象是Json,在哪里是存储?

谢谢。

您试图在c++中使用终端命令,这将不起作用。X是curl的命令行选项。

下面是Curl使用c提交HTTP POST请求的基本示例,您应该能够根据自己的需要进行调整。

http://curl.haxx.se/libcurl/c/http-post.html