tags:

views:

37

answers:

1

Hi.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">
<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?

+1  A: 

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("&parameter1=");
postParams.append("data");
postParams.append("&parameter2=");
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
}
Error 454
You should explain how the parameters work. It is not intuitive for beginners. Also the OP provides you with the names of the parameters so it would be nice if you use those in your answer.
Martin York