0

嗨,我是 Tizen 开发的新手,想探索我在 android 开发中使用的功能/特性。所以我想学习如何使用 Native Tizen 手表发布/获取 HTTP 并解析来自 URL 的 json 响应。任何人都可以帮助我或指出一些教程吗?

4

1 回答 1

0

您可以使用curl. 这是一个使用示例

添加这些标题

#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);
  }

您也可以查看此链接和此链接

教程:这个

于 2016-10-21T16:12:15.763 回答