Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.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
需要帮助将php curl代码转换为C语言吗_Php_C_Curl - Fatal编程技术网

需要帮助将php curl代码转换为C语言吗

需要帮助将php curl代码转换为C语言吗,php,c,curl,Php,C,Curl,我的服务提供商为我提供了下面一段PHP代码来访问他的服务。我需要帮助转换为C语言代码,以便在我的应用程序中使用。代码使用curl模块发布到站点。 请告知 <?php $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, "http://api.mVaayoo.com/mvaayooapi/MessageCompose?user="myusername":"mypassword"&senderID=TEST SMS&receipi

我的服务提供商为我提供了下面一段PHP代码来访问他的服务。我需要帮助转换为C语言代码,以便在我的应用程序中使用。代码使用curl模块发布到站点。 请告知

<?php
$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,  "http://api.mVaayoo.com/mvaayooapi/MessageCompose?user="myusername":"mypassword"&senderID=TEST SMS&receipientno="phonenum"&msgtxt=This is a test from mVaayoo API&state=4");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$user&senderID=$senderID&receipientno=$receipientno&cid=$cid&msgtxt=$msgtxt");

$buffer = curl_exec($ch);

if(empty ($buffer))
{ echo " buffer is empty "; }
else
{ echo $buffer; }
curl_close($ch);
?>

使用它的C接口。remainer是一个很好的旧C风格字符串处理程序。

注释中的示例libcurl程序看起来不错,只是对于一篇文章,您需要安装一个CURLOPT_READFUNCTION,而不是CURLOPT_WRITEFUNCTION。但是,如果您只想发布一个静态缓冲区,请使用CURLOPT_POSTFIELDS而不是回调函数。

我尝试过libcurl,但它不起作用。下面是我的工作,程序被困在curl\u easy\u执行中,永远不会返回。int mainvoid{CURLcode res;curl*curl=curl\u easy\u init;ifcurl{curl_easy_setoptcurl,CURLOPT_URL,curl_easy_setoptcurl,CURLOPT_POST,1;curl_easy_setoptcurl,CURLOPT_CONNECTTIMEOUT,1L;curl_easy_setoptcurl,CURLOPT_TIMEOUT,1L;curl_easy_setoptcurl,CURLOPT_WRITEFUNCTION,write_回调;res=curl_easy_性能URL;如果res!=CURLE_OK fprintfstderr,失败:%s,curl\u easy\u strerres;curl\u easy\u cleanupcurl;}返回-1;}出于保密原因,我删除了URL部分。