如何使用 Native 在 TIZEN 手表中发送 HTTP 请求并解析 JSON 响应?

How to sendi HTTP request and parse JSON response in TIZEN watch using Native?

您好,我是 Tizen Development 的新手,想像我在 android 开发中使用的那样探索 functions/features。因此,我想学习如何 post/get HTTP 并使用 Native Tizen watch 解析来自 URL 的 json 响应。任何人都可以帮助我或指出一些教程吗?

您可以使用 curl 执行此操作。这是一个 example 使用:

添加这些headers

#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 and this link

教程:This