PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Dec 14, 2017 7:44 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: cURL Fails To Auto Post
PostPosted: Mon Oct 30, 2017 4:53 pm 
Offline
Forum Contributor

Joined: Wed Jan 18, 2017 4:43 pm
Posts: 179
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:
https://www.atilus.com/top10internetmarketingblogs/

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@email.com";
$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;
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group