473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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:
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 ?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $postfields = array();
  3. $postfields["action"] = "submit";
  4. $postfields["author"] = "programmer";
  5. $postfields["email"] = "email@email.com";
  6. $postfields["url"] = "http://www.example.com/";
  7. $postfields["comment"] = "Testing comment 1,2,3.";
  8. $postfields["comment_post_ID"] = "123";
  9. $postfields["_wp_unfiltered_html_comment"] = "0d870b294b";
  10. //Url of the form submission
  11. $url = "https://www.atilus.com/top10internetmarketingblogs/";
  12. $useragent = "Mozilla/5.0";
  13. $referer = $url; 
  14.  
  15. //Initialize CURL session
  16. $ch = curl_init($url);
  17. //CURL options
  18. curl_setopt($ch, CURLOPT_POST, 1);
  19. //We post $postfields data
  20. curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
  21. //We define an useragent (Mozilla/5.0)
  22. curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
  23. //We define a refferer ($url)
  24. curl_setopt($ch, CURLOPT_REFERER, $referer);
  25. //We get the result page in a string
  26. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  27. //We exits CURL
  28. $result = curl_exec($ch);
  29. curl_close($ch);
  30.  
  31. //Finally, we display the result
  32. echo $result;
  33. ?>
  34.  
Oct 30 '17 #1
0 3317

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John | last post by:
This does a little beyond PHP, but I'm looking for a script to use on a php website that will grab my current away message from either AIM, IRC, ICQ, Jabber, Yahoo, or MSN; as I use trillian pro...
2
by: Rob Meade | last post by:
Hi all, I need to know how to determine if I arrived at my postback because of the dropdownmenu or whether because of a form button being clicked. How can I achieve this? Any information...
9
by: junlia | last post by:
Does anyone how how can we disable the auto-postback feature in asp.net page? I have to use a server side control in the page, but the auto post back feature in it causes problems for me. Please...
2
by: panyb | last post by:
Hi, Can anybody help to look into this: I have an intranet site, everytime when I want to collect data, users go to the page, login, input form data and submit. And now, I have a lot of datas in...
4
by: dschruth | last post by:
Hello. Can anybody solve this problem? I am using a server-side language (PERL) to *try* to POST data to a HTTPS login script that doesn't have a standard "submit" button. The form appears...
1
by: David W | last post by:
How can I make a redirection (like a header('Location:/xxx') ) with post values ?
1
by: mazdotnet | last post by:
Hi, I'm doing a trial with InternetSecure (credit card verification) and it requires the following step, Your site connects to InternetSecure and passes us the purchase information in a FORM...
4
by: BinnyVA | last post by:
Hi, I am using PHP 5.1.2 with curl enabled. But whenever I try to use curl to fetch a url, it fails - 'curl_exec()' returns nothing. But if I try to execute the same file in CLI - like 'php...
11
by: C10B | last post by:
hi all, I have 3 drop down lists. When any of them changes there is an auto postback to do some server stuff. It is not always obvious (as a user) that a page reload has been started, and you...
2
by: scotty | last post by:
I have a ListBox with AutoPostBack='True'. The corresponsing form is set as follows: <form runat='server' method='POST' action='results.asp' name='mbrlst_search' ID='search_form'> When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.