您可以使用
curl
。这是
example
使用:
#include <curl/curl.h>
#include <net_connection.h>
/* Initialize CURL */
CURL *curlHandler = curl_easy_init();
connection_h connection;
int conn_err;
conn_err = connection_create(&connection);
if (conn_err != CONNECTION_ERROR_NONE) {
/* Error handling */
return false;
}
if(curlHandler) {
/* Set CURL parameters */
curl_easy_setopt(curlHandler, CURLOPT_URL, "http://api.yoururl.com");
curl_easy_setopt(curlHandler, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curlHandler, CURLOPT_POSTFIELDS, jObj);
/* Perform the request */
CURLcode res = curl_easy_perform(curlHandler);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "CURL failed: %s\n",
curl_easy_strerror(res));
/* Clean up */
curl_easy_cleanup(curlHandler);
json_object_object_del(jObj, "name");
connection_destroy(connection);
free(jObj);
}
你也可以检查这个
link
这个
link
.
辅导的:
This