http - Error while connecting to wit api url using curl library in C code -


purpose : response of wit api using curl library using c

source code :

#include <stdio.h> #include <string.h> #include <curl/curl.h>  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 don't provide postfieldsize, libcurl strlen()    */     curl_easy_setopt(curl, curlopt_postfieldsize, (long)strlen(postthis));  /* perform request, res return code */  res = curl_easy_perform(curl); /* check errors */    if(res != curle_ok)    fprintf(stderr, "curl_easy_perform() failed: %s\n",           curl_easy_strerror(res));  /* cleanup */     curl_slist_free_all(list);    curl_easy_cleanup(curl);   } return 0; } 

$token authentication token of wit api

error: bad auth, check token/params


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -