Return to Snippet

Revision: 31030
at August 29, 2010 01:10 by ksaver


Updated Code
#! /usr/bin/env bash
#  unfollow_nofriends.sh
#  unfollow twitter users not following back to you.
#  ksaver (at identi.ca), Aug, 2010.
#  uses friendorfollow.com csv file at:
#  "http://friendorfollow.com/$USERNAME/results/?\
#  orderby=undefined&type=following&format=csv"
#  and twitter API at:
#  "http://api.twitter.com/1/friendships/destroy/$ID.xml"
#  Requieres: curl, egrep, in order to work properly.
#  This script has been written to help in some twitter account maintanance,
#  please do not use it for evil pourposes :-)
#  Public Domain Code.
#  Not warranty at all.

# Edit this two lines according to your correct twitter account:
USERNAME='username123'
PASSWORD='password321'

TWIT_AUTH="$USERNAME:$PASSWORD"
TWIT_API="http://api.twitter.com/1/friendships/destroy"
FOF_CSV="http://friendorfollow.com/$USERNAME/results/?orderby=undefined&type=following&format=csv"
ERR=0
OK=0

function _curl()
{
    /usr/bin/env curl -s -A 'Mozilla' "$@"
}

function get_nofriend_list()
{
    _curl "$FOF_CSV" |cut -d',' -f2 |egrep -e [0-9]
}

function unfollow_id()
{
    ID="$1"
    _curl -u "$TWIT_AUTH" -d '' "$TWIT_API/$ID.xml" \
    |grep '<error>' > /dev/null && return 1 || return 0
}

function error_msg()
{
    ID="$1"
    echo "Error unfollowing user with ID: $ID"
}

function __main__()
{
    ## Getting no-friend list in an Array...
    NOFRIENDS=( $(get_nofriend_list) )

    echo "Unfollowing ${#NOFRIENDS[@]} total users..."
    for id in ${NOFRIENDS[@]}
    do
        unfollow_id $id && let OK=$OK+1 || (error_msg $id && let ERR=$ERR+1)
    done

    echo "$OK total no-friend users unfollowed and $ERR errors."
}

## Run script if not called by source.
if [ "$0" != 'bash' ]
then
    __main__
fi

Revision: 31029
at August 27, 2010 17:21 by ksaver


Updated Code
#! /usr/bin/env bash
#  unfollow_nofriends.sh
#  unfollow twitter users not following back to you.
#  ksaver (at identi.ca), Aug, 2010.
#  uses friendorfollow.com csv file at:
#  "http://friendorfollow.com/$USERNAME/results/?\
#  orderby=undefined&type=following&format=csv"
#  and twitter API at:
#  "http://api.twitter.com/1/friendships/destroy/$ID.xml"
#  Requieres: curl, egrep, in order to work properly.
#  This script has been written to help in some twitter account maintanance,
#  please do not use it for evil pourposes :-)
#  Public Domain Code.
#  Not warranty at all.

# Edit this two lines according to your correct twitter account:
USERNAME='username123'
PASSWORD='password321'

TWIT_AUTH="$USERNAME:$PASSWORD"
TWIT_API="http://api.twitter.com/1/friendships/destroy"
FOF_CSV="http://friendorfollow.com/$USERNAME/results/?orderby=undefined&type=following&format=csv"
ERR=0
OK=0

function _curl()
{
    /usr/bin/env curl -s -A 'Mozilla' "$@"
}

function get_nofriend_list()
{
    _curl "$FOF_CSV" |cut -d',' -f2 |egrep -e [0-9]
}

function unfollow_id()
{
    ID="$1"
    _curl -u "$TWIT_AUTH" -d '' "$TWIT_API/$ID.xml" \
    |grep '<error>' > /dev/null && return 1 || return 0
}

function error_msg()
{
    ID="$1"
    echo "Error unfollowing user with ID: $ID"
}

function __main__()
{
    ## Getting no-friend list in an Array...
    NOFRIENDS=( $(get_nofriend_list) )

    echo "Unfollowing ${#NOFRIENDS[@]} total users..."
    for id in ${NOFRIENDS[@]}
    do
        unfollow_id $id && let OK=$OK+1 || error_msg $id && let ERR=$ERR+1
    done

    echo "$OK total no-friend users unfollowed and $ERR errors."
}

## Run script if not called by source.
if [ "$0" != 'bash' ]
then
    __main__
fi

Revision: 31028
at August 27, 2010 15:01 by ksaver


Initial Code
#! /usr/bin/env bash
#  unfollow_nofriends.sh
#  unfollow twitter users not following back to you.
#  ksaver (at identi.ca), Aug, 2010.
#  uses friendorfollow.com csv file at:
#  "http://friendorfollow.com/$USERNAME/results/?orderby=undefined&type=following&format=csv"
#  and twitter API: "http://api.twitter.com/1/friendships/destroy/$ID.xml"
#  Requieres: curl, egrep, in order to work properly.
#  This script has been written to help in some twitter account maintanance,
#  please do not use it for evil pourposes :-)
#  Public Domain Code.
#  Not warranty at all.

# Edit this two lines according to your correct twitter account:
USERNAME='username123'
PASSWORD='password321'

TWIT_AUTH="$USERNAME:$PASSWORD"
TWIT_API="http://api.twitter.com/1/friendships/destroy"
FOF_CSV="http://friendorfollow.com/$USERNAME/results/?orderby=undefined&type=following&format=csv"
ERR=0
OK=0

function _curl()
{
    /usr/bin/env curl -s -A 'Mozilla' "$@"
}

function get_nofriend_list()
{
    _curl "$FOF_CSV" |cut -d',' -f2 |egrep -e [0-9]
}

function unfollow_id()
{
    ID="$1"
    _curl -u "$TWIT_AUTH" -d '' "$TWIT_API/$ID.xml" \
    |grep '<error>' > /dev/null && return 1 || return 0
}

function error_msg()
{
    ID="$1"
    echo "Error unfollowing user with ID: $ID"
}

function __main__()
{
    ## Getting no-friend list in an Array...
    NOFRIENDS=( $(get_nofriend_list) )

    echo "Unfollowing ${#NOFRIENDS[@]} total users..."
    for id in ${NOFRIENDS[@]}
    do
        unfollow_id $id && let OK=$OK+1 || error_msg $id && let ERR=$ERR+1
    done

    echo "$OK total no-friend users unfollowed and $ERR errors."
}

## Run script if not called by source.
if [ "$0" != 'bash' ]
then
    __main__
fi

Initial URL
http://identi.ca/ksaver

Initial Description
Also posted at http://pastebin.com/9FzakUcd

Initial Title
Unfollow all twitter users  not following back to you

Initial Tags
twitter

Initial Language
Bash