Nov 18, 2009

Replying to Facebook mail on command line

this is a little helper script that I wrote to use in conjunction with FBCMD to reply to inbox messages directly on the command line without going to the website.

It takes two args, the message number (as given out by fbcmd inbox) and the message itself. pretty straightforward. Just throwing it out there.

it's meant to be used with fbcmd, but if you like you can provide a thread_id to it as well (slight mod might be needed)



#!/usr/bin/perl

use strict;
use WWW::Mechanize;
use HTTP::Cookies;

my $username = 'youremail';
my $password = 'yourpass';
my $maildata = "/home/youruser/.fbcmd/maildata.txt";

my $msgid=`php -r \"\\\$ld=unserialize(file_get_contents('$maildata'));print \\\$ld['ids'][$ARGV[0]];\"`;

my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());

$mech->get("http://lite.facebook.com/login/");
$mech->submit_form(form_number => 1,fields =>{email=>$username,password=>$password});

$mech->content() =~ /\/w\/(\w+)\/logout/;
$mech->post("http://lite.facebook.com/w/".$1."/inbox/reply/".$msgid."/",{message=>$ARGV[1],__async__=>'true'});

4 Comments:

Anonymous said...

tested.works.

Anonymous said...

you have too much time

SoE said...

yes I do

SoE said...

up: does not work since facebook disabled their "Facebook lite" service.

Post a Comment