/    Sign up×
Community /Pin to ProfileBookmark

cURL Fails To Auto Post

Hi,

I was searching for a tutorial that teaches how cURL can auto post and came across the following code. It is supposed to fill-in WP comment form. But for some reason I see no response on the commenting section on the blog:
[url]https://www.atilus.com/top10internetmarketingblogs/[/url]

Why is that ?
If I run the script on my site then I see cURL fetches the page (the above link) but I see no response on the comment form.
If I run the script on my Xampp (localhost) then I see a complete white blank page. Why ?

[code]
<?php
$postfields = array();
$postfields[“action”] = “submit”;
$postfields[“author”] = “programmer”;
$postfields[“email”] = “[email protected]”;
$postfields[“url”] = “http://www.example.com/”;
$postfields[“comment”] = “Testing comment 1,2,3.”;
$postfields[“comment_post_ID”] = “123”;
$postfields[“_wp_unfiltered_html_comment”] = “0d870b294b”;
//Url of the form submission
$url = “https://www.atilus.com/top10internetmarketingblogs/”;
$useragent = “Mozilla/5.0”;
$referer = $url;

//Initialize CURL session
$ch = curl_init($url);
//CURL options
curl_setopt($ch, CURLOPT_POST, 1);
//We post $postfields data
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
//We define an useragent (Mozilla/5.0)
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
//We define a refferer ($url)
curl_setopt($ch, CURLOPT_REFERER, $referer);
//We get the result page in a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//We exits CURL
$result = curl_exec($ch);
curl_close($ch);

//Finally, we display the result
echo $result;
?>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@rootOct 31.2017 — Moved to a more appropriate forum.
Copy linkTweet thisAlerts:
@NogDogOct 31.2017 — Does form submission require that you be logged in? If so, you'll probably have to do that first, capture the session cookie (if that's how it controls login), and then include that cookie in the headers for the form submission.
×

Success!

Help @site-developer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...