title: Error while connecting to wit api url using curl library in C code
body: <p>Purpose : To get the response of the Wit API using curl library using C</p>
  
  <p>Source code : </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;curl/curl.h&gt;
  
  int main(void)
  {
    CURL *curl;
    CURLcode res;
    struct curl_slist *list = NULL;
  
    static const char *postthis="q=hello";
  
    curl = curl_easy_init();
    if(curl) {
      curl_easy_setopt(curl, CURLOPT_URL, "https://api.wit.ai/message);
  
      list = curl_slist_append(list, "Authorization: Bearer $TOKEN");
      curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
  
      curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
  
  /* if we don't provide POSTFIELDSIZE, libcurl will strlen() by
     itself */ 
     curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis));
  
  /* Perform the request, res will get the return code */ 
  res = curl_easy_perform(curl);
  /* Check for errors */ 
    if(res != CURLE_OK)
     fprintf(stderr, "curl_easy_perform() failed: %s\n",
            curl_easy_strerror(res));
  
  /* always cleanup */ 
     curl_slist_free_all(list);
     curl_easy_cleanup(curl);
    }
  return 0;
  }
  </code></pre>
  
  <p>$TOKEN is the authentication token of Wit Api</p>
  
  <p>Error: Bad auth, check token/params</p>