开发者

Http posting a comment to wordpress in c

开发者 https://www.devze.com 2023-01-15 16:32 出处:网络
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\

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("&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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号