31.05.2007

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”

  1. SEOidiot Says:

    Π‘ΠΎΠ΅Π΄ΠΈΠ½ΠΈΡ‚Π΅ Π²ΠΈΡ‚ΠΎΠΊ ΠΌΠ°Π½Π³ΠΎΠ°, ΡΠΌΠ΅Ρ€Ρ‚ΡŒ ΠΊ mongers расстСгая capatalist

  2. m1t0s1s Says:

    Connect round mangoa, death to mongers rasstegaya capatalist? heh

  3. gnarlyguy Says:

    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?

  4. The Kaptain Says:

    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”

  5. jameswillisisthebest Says:

    This is my first post
    just saying HI

  6. netizen Says:

    pie! loooots of pie!

  7. Agus Says:

    nice script, thanks

Leave a Reply


Clicky Web Analytics
taky