I can't post comment to wordpress page in c using curl.I tried formadd but it didn't happen again.
<input id="author" name="author" type="text" value="" size="30" aria-required="true">
<input id="email" name="email" type="text" value="" size="30" aria-required="true">
&l开发者_Python百科t;input id="url" name="url" type="text" value="" size="30">
<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>
<input name="submit" type="submit" id="submit" value="Yorum Yaz">
How I should post?
Here is a simple curl example. If the requirement is for strict C and not C++, change the std::string below to a char array.
CURL *curl;
CURLcode res;
std::string postParams;
//Set parameters
postParams.clear();
postParams.append("¶meter1=");
postParams.append("data");
postParams.append("¶meter2=");
postParams.append("more data");
//Initialize curl
curl = curl_easy_init();
if(curl){
//Set site
curl_easy_setopt(curl, CURLOPT_URL, "http://www.yoursite.com");
//Use post, set parameters
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *)postParams.c_str());
//Perform the session
res = curl_easy_perform(curl);
//Cleanup the session
curl_easy_cleanup(curl);
}
if(res == 0){
//Success
}
else{
//Failure
}
精彩评论