Jun 12, 2010

Bulk responding to facebook wallposts

So it happens that my birthday is coming up, and like last year there's bound to be a shitload of posts on my Facebook wall...and like last time I'm probably expected to respond to said posts otherwise I'd be "rude".

Here's the dilema though, I can't be bothered to spend all the time going through the wall, clicking on links..responding blah blah. What I'd like to do, is respond to all of them in bulk. So here's my solution...

1.download all wallposts to a csv file
2.edit said csv file and add responses to those posts that i want to respond to
3.send off said responses.

How-to after the jump

Prerequisites get FBCMD and set it up. Grant it stream_read and stream_publish permissions.

Save this perl script somewhere and name it..err..say..respond.pl

while you're at it, install the perl CSV parser library (from CPAN or you can do a "sudo apt-get install libtext-csv-perl")

#!/usr/bin/perl

use Text::CSV;
my $csv = Text::CSV_XS->new();
open(CSV, $ARGV[0]) or die "open: $ARGV[0]: $!\n";
my $pid,$text;
while (defined ($_ = <csv>)) {
s/, /,/;
$csv->parse($_) or warn("invalid CSV line: ", $csv->error_input(), "\n"), next;
my @fields = $csv->fields();

if($fields[3]) {
system("fbcmd","comment",$fields[0],$fields[3])
}
}
close(CSV) or die"close: $ARGV[0]: $!\n"


Step One. grab the wallposts - run this.

fbcmd mywall 100 -csv -sbr=0 -hdr=0 | sed 's/\[//;s/\]//' | tee stream.csv

NOTE: change the 100 to whatever you like if you want more posts to display

Step Two. open the file up in Open Office Spreadsheet or something and add your responses to a new column.

eg: the original file
1,"joe dirt","lets eat some dirt"
4,"ugly joe","man you're ugly"
after the edit
1,"joe dirt","lets eat some dirt","no wai man"
4,"ugly joe","man you're ugly","goddamnit man!"

now save it...make sure you keep the file format.

Step Three. run the perl script on it!

perl respnd.pl stream.csv

and voila! semi automatic hassle free responding to facebook birthday wishes|greetings on facebook using command line bash perl fbcmd blah blah... (yes that was for the search engines)

7 Comments:

Anonymous said...

happy birthday!

ÎĦΣçҜәѓ™ said...

haha! Cool! XD

Anonymous said...

I love all your little facebook tips and tricks.

Thanks

Jaa said...

Interesting way to interact on Facebook! Quite ingenious :)

andhu said...

bragging about how u would do it doesnt make u rude at all!

SoE said...

It's rude NOT to do it... it doesn't matter HOW you do it.

aliul said...

I'm not too great about remembering birthdays so I use birthdayFB. It let's you pre-schedule happy birthday fb wall posts. http://bityhdayfb.com

Post a Comment