PoshCode Archive  Artifact [eeb03e321e]

Artifact eeb03e321ee0bb5fa7a032a5bfcefb69fe45b6d09df9d5a8a7018bea1e6825ee:

  • File Compare-TwitterNames.ps1 — part of check-in [56c5f552d7] at 2018-06-10 14:25:38 on branch trunk — This script will compare the names of the people you follow on Twitter and the people following you. It returns a comparison object consisting of the Twitter name of a subject and a side indicator – “<=” means that you are following a subject who is not following you, “=>” means that you are followed by someone who you are not following. (user: Steven Murawski size: 2186)

# encoding: ascii
# api: powershell
# title: Compare-TwitterNames.ps1
# description: This script will compare the names of the people you follow on Twitter and the people following you.  It returns a comparison object consisting of the Twitter name of a subject and a side indicator – “<=” means that you are following a subject who is not following you, “=>” means that you are followed by someone who you are not following.
# version: 0.1
# type: script
# author: Steven Murawski
# license: CC0
# x-poshcode-id: 871
# x-archived: 2017-03-12T01:08:10
# x-published: 2009-02-16T07:21:00
#
#
#This script will compare the names of the people you follow on Twitter
#and the people following you.  It returns a comparison object consisting 
#of the Twitter name of a subject and a side indicator - 
#"<=" means that you are following a subject who is not following you, 
#"=>" means that you are followed by someone who you are not following.

function GetTwitterNames([string]$query)
{   
    $wc = new-object System.Net.WebClient
    $wc.Credentials = $script:credential.GetNetworkCredential()

    $nbrofpeople = 0
    $page = "&page="
    $names = @()

    do 
    {
        $url = $query
        if ($nbrofpeople -gt 0)
        {
            $url = $url+$page+($nbrofpeople/100 +1)
        }

        [xml]$nameslist = $wc.DownloadString($url)

        $names += $nameslist.users.user | select name

        $nbrofpeople += 100
    } while ($names.count -eq $nbrofpeople)

    return $names
}

$twitter = "http://twitter.com/statuses/"
$friends = $twitter + "friends.xml?lite=true"
$followers = $twitter + "followers.xml?lite=true"

$credential = Get-Credential

$friendslist = GetTwitterNames($friends)
$followerslist = GetTwitterNames($followers)

$sync = 0
if ($friendslist.count -gt $followerslist.count)
{
	$sync = ($friendslist.count)/2
}
else
{
	$sync = ($followerslist.count)/2
}

$Status = @{Name='Status';Expression={if ($_.sideindicator -like '=>') {'Followed By'} else {'Following'}}}

compare-object $friendslist $followerslist -SyncWindow ($sync) -Property name | Select-Object Name, $Status