Changes from the old version
1. Added some error checking should now detect failed/successful logins, and update attempt.
2. writes cookies to /tmp/ instead of $HOME
Not much of a changelog I know, but I suppose this makes for pretty much all the updating that this script would require. Don't forget to check out how to run this on the iPhone, although it does seem quite unnecessary since the Facebook app is pretty good.
#!/bin/bash
email=YOUR-EMAIL
pass=YOUR-PASSWORD
stat=$1
cookie="/tmp/"$RANDOM"fupdate"$RANDOM"cookiefile"
if [ -z "${stat}" ]
then
echo -e "\n\E[01musage\E[0m: \n fupdate 'your new status message'\n"
echo -e "The status should not be empty\n"
exit 1
fi
echo -n "Trying to log in..."
pfID=`curl -L --silent -A "MOZILLA/5.0" -b ${cookie} -c ${cookie} -d "email=${email}" \
-d "pass=${pass}" -d "login=Log+In" http://m.facebook.com/login.php | \
sed -nr 's/.*post_form_id" value="(\w+)".*/\1/p'`
if [ -z ${pfID} ];then echo "FAILED (no pfID)";exit 1;else echo "SUCCESS!";fi
echo -n "Trying to update..."
return=`curl --silent -L -A "MOZILLA/5.0" -b ${cookie} -c ${cookie} \
-d "post_form_id=${pfID}" -d "status=${stat}" \
-d "update=Update" http://m.facebook.com/home.php | \
sed -nr 's/.*(Your status has been updated).*/\1/p'`
if [ -z "${return}" ];then echo "FAILED";exit 1;else echo "SUCCESS!";fi
if [ -e ${cookie} ]
then
rm ${cookie}
else
echo "no cookie file? something went wrong?"
exit 1
fi
11 Comments:
you know facebook isn't really going to like you doing this? It tried to shtdown a php based version of this some time ago. But either way this thing rocks and gets the job done.
you know facebook isn't really going to like you doing this? It tried to shtdown a php based version of this some time ago. But either way this thing rocks and gets the job done.
you know facebook isn't really going to like you doing this? It tried to shtdown a php based version of this some time ago. But either way this thing rocks and gets the job done.
sorry for the triple post,something went wrong with my browser.
sorry for the triple post,something went wrong with my browser.
sorry for the triple post,something went wrong with my browser.
@Anon.This is a useful script. why would facebook not like it?. It ain't used for spamming or anything like that.
I don't think they really like people going outside the official API, I'm told they took out a php/cURL hack some time ago. I haven't received any threatening emails yet :)
Is there a current version of this? This script reports failure. I want this to update from a webpage, but just don't want to mess with the API, I'd rather do it via bash or PHP with curl.
please use FBCMD. It uses the API and can be pretty easily integrated into a website.
http://fbcmd.dtompkins.com/
There is a new script for that on:
http://360percents.com/posts/bash-script-to-update-facebook-status-linux-mac-os-x/
Post a Comment