Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript C-带libcurl的http post请求_Javascript_C_Node.js_Post_Curl - Fatal编程技术网

Javascript C-带libcurl的http post请求

Javascript C-带libcurl的http post请求,javascript,c,node.js,post,curl,Javascript,C,Node.js,Post,Curl,我正在使用处的代码尝试向我经常成功使用但使用nodejs/javascript的web服务发出post请求。我可以从javascript获得post请求,但不能从使用libcurl的C获得post请求 我的C代码与上面链接中的代码基本相同 #include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; /* In windows, this will in

我正在使用处的代码尝试向我经常成功使用但使用nodejs/javascript的web服务发出post请求。我可以从javascript获得post请求,但不能从使用libcurl的C获得post请求

我的C代码与上面链接中的代码基本相同

#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
  CURL *curl;
  CURLcode res;
  /* In windows, this will init the winsock stuff */
  curl_global_init(CURL_GLOBAL_ALL);
  /* get a curl handle */
  curl = curl_easy_init();
  if(curl) {
       /* First set the URL that is about to receive our POST. This URL can just as well be a https:// URL if that is what should receive the data. */
  curl_easy_setopt(curl, CURLOPT_URL, "http://webservice.i.use.com/this/that");
       /* Now specify the POST data */
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "token=TOKEN&product=PROD&timeinterval=ONE_MINUTE&datetime=2013-10-22+19:10")
       /* 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_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
nodejs
needle
包正在发送一些额外的信息,而这些信息不是与上面的C代码一起发送的吗

我还尝试了
curl
CLT

curl -data "token=...." "url ...."
但这也不起作用


最近修改了处的代码,以得到与上面相同的身份验证错误消息。任何帮助都将不胜感激

已解决,令牌值中有一个“+”,它必须是%2B

var needle = require('needle')
needle.post('http://webservice.i.use.com/this/that',
    {token:'TOKEN' , product:'PROD' , timeinterval:'ONE_MINUTE' , datetime:'2013-10-22+19:10'},·
    function(err, resp, body){
       console.log(body);
    });
curl -data "token=...." "url ...."