Simple PHP WordPress Comment Poster
The Kaptain was porting this from ColdFusion and wasn’t even going to post it because with using the Snoopy class it’s so simple anyone should be able to spend 5 minutes coding it. But for the sake of the few that can’t (or are too lazy to), we decided to post it.
This WordPress Blog Comment Poster Script will take a URL and an array of data which is required to post a comment on a wordpress blog. The URL is simply the URL of the blog you want to post a comment on.
You will notice that you need a “comment_post_id” in the array. This is the post ID of the post to which you will be leaving the comment. You can either use the PHP rand() function to guess one for you or you can harvest them on your own. If you are really lucky the Kaptain will whip a harvester up quick and post it for you to use. For now though, this is all you get.
With a little bit of work you could automate your comment posting by pulling information from a database or text file and running this script on a schedule (cron jobs anyone?). Nothing like sending out 40 million comments every day to let people know how much your website rules.
Enough jabbering, here is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | include("Snoopy.class.php"); function postWPComment($wpURL,$aInfo){ //action page of the comment form $postPage = "wp-comments-post.php"; //new URL with postPage attached (like magic!) $wpURL = $wpURL."/".$postPage; //SNOOPY! $snoopy = new Snoopy; $page = $snoopy->submit($wpURL,$aInfo); $page = $snoopy->results; return $page; } |
The usage is equally as simple:
1 2 3 4 5 6 7 8 9 10 11 | $info = array(); $info['author'] = 'test'; $info['email'] = 'email@test.com'; $info['url'] = "http://www.kaptainkrayola.com"; $info['comment'] = "Mangoes support communism"; $info['comment_post_id'] = 1; $useURL = "http://www.someblog.com/"; //post that comment, biatch! echo postWPComment($useURL,$info); |
This comment poster is really simple and should be easily incorporated into your existing set of tools. If you have any questions or comments feel free to leave them here and The Kaptain will get back to you whenever he damned well feels like it.

7 Responses to “Simple PHP WordPress Comment Poster”
June 3rd, 2007 saat: 2:29 pm
Соедините виток мангоа, Ñмерть к mongers раÑÑÑ‚ÐµÐ³Ð°Ñ capatalist
June 4th, 2007 saat: 6:24 pm
Connect round mangoa, death to mongers rasstegaya capatalist? heh
June 10th, 2007 saat: 9:56 pm
Thanks for releasing this Kaptain. Could you be kind enough to show me how to grab the URLs from a flatfile instead of hardcoding it into the script? Yes I’m lame and don’t know PHP but making the effort to learn it.
BTW … care to explain the term mango?
June 11th, 2007 saat: 8:25 am
gnarlyguy:
You’ll want to check out how to get the contents out of the file first. Then you’ll want to check out how to loop over the file contents you just got. With each iteration you’ll want to call the function postWPComment() (above) and pass in the required information.
The Kaptain could give you the answers and all the code to do it but making you go look it up yourself (php.net) will help you a lot more. The whole give a man a fish/teach a man to fish deal.
Mango? Google says they are: “large oval tropical fruit having smooth skin, juicy aromatic pulp, and a large hairy seed”
September 8th, 2007 saat: 4:09 pm
This is my first post
just saying HI
September 26th, 2007 saat: 3:15 pm
pie! loooots of pie!
August 10th, 2008 saat: 5:50 am
nice script, thanks
Leave a Reply
You must be logged in to post a comment.