PoshCode Archive  Artifact [e0b4c9663e]

Artifact e0b4c9663e0021ee693e068318c45a7301ca45a1f2eb0613201564a63bbe40c3:

  • File Compare-TwitterNames.ps1 — part of check-in [c63024319e] at 2018-06-10 13:48:37 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: 2009)

# 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: 500
# x-archived: 2009-01-06T14:47:22
#
#
#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
}

compare-object $friendslist $followerslist -SyncWindow ($sync) -Property name