From 359f5330fae44dfdfb1c13a362bba3578ace82e7 Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 09:48:56 -0500 Subject: [PATCH 01/10] Added new lists command to the help command --- script.php | 1 + 1 file changed, 1 insertion(+) diff --git a/script.php b/script.php index d9f5f14..1d726d8 100644 --- a/script.php +++ b/script.php @@ -26,6 +26,7 @@ echo "tw info - Get User Info\r"; echo "tw follow - Follow user\r"; echo "tw unfollow - Unfollow user\r"; + echo "tw lists - Show lists\r"; echo "tw add - Add user to list\r"; echo "tw remove - Remove user from list\r"; echo "tw block - Block user\r"; From 3348608cf9fb4da4a6a3aa5107002c86860060b2 Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 09:51:33 -0500 Subject: [PATCH 02/10] Removed some testing code that I forgot about! --- script.php | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/script.php b/script.php index 1d726d8..3ce96ba 100644 --- a/script.php +++ b/script.php @@ -327,6 +327,41 @@ } + else if ($input[0] == "lists") { + + $username = $input[1]; + $list = $input[2]; + unset($input[0]); + unset($input[1]); + unset($input[2]); + $message = implode(" ", $input); + + // check authentication status + $auth = check_auth(); + + // If oauth values aren't set, assumed that the user hasn't run setup yet. + if ($auth == false) { + echo "Unable to send dm. You must run setup and authenticate first."; + } + else { + + // get logged in user's screen_name + $screen_name = get_screen_name(); + + // create a new instance + $tweet = new TwitterOAuth($appkey1, $appkey2, $auth['oAuthKey'], $auth['oAuthSecret']); + + // add user to list + $res = $tweet->post('lists/members/create', array('screen_name' => $username, 'slug' => $list, 'owner_screen_name' => $screen_name)); + + // display result + if (isset($res->error)) { echo $res->error; } + else { echo "$username successfully added to the $list list!"; } + + } // end else + + } + else if ($input[0] == "add") { $username = $input[1]; @@ -347,7 +382,6 @@ // get logged in user's screen_name $screen_name = get_screen_name(); - $result = system("echo $screen_name > screen_name.txt"); // create a new instance $tweet = new TwitterOAuth($appkey1, $appkey2, $auth['oAuthKey'], $auth['oAuthSecret']); @@ -383,7 +417,6 @@ // get logged in user's screen_name $screen_name = get_screen_name(); - $result = system("echo $screen_name > screen_name.txt"); // create a new instance $tweet = new TwitterOAuth($appkey1, $appkey2, $auth['oAuthKey'], $auth['oAuthSecret']); From fc989b18faa2e2afb0d79553f6fca8359b42ef24 Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 10:00:34 -0500 Subject: [PATCH 03/10] Setup command to show the current user's lists --- script.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/script.php b/script.php index 3ce96ba..99affcc 100644 --- a/script.php +++ b/script.php @@ -352,11 +352,17 @@ $tweet = new TwitterOAuth($appkey1, $appkey2, $auth['oAuthKey'], $auth['oAuthSecret']); // add user to list - $res = $tweet->post('lists/members/create', array('screen_name' => $username, 'slug' => $list, 'owner_screen_name' => $screen_name)); + $res = $tweet->post('lists', array('screen_name' => $screen_name)); - // display result + //display result(s) if (isset($res->error)) { echo $res->error; } - else { echo "$username successfully added to the $list list!"; } + else { + $inc=1; + foreach($res->results as $result): + echo "$result->slug\r\r"; } + $inc++; + endforeach; + } } // end else From 18d29c6113f23bed9e8660bd9142a82bebc26e2e Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 10:01:35 -0500 Subject: [PATCH 04/10] Updated error comments to reflect commands properly --- script.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script.php b/script.php index 99affcc..fe29c34 100644 --- a/script.php +++ b/script.php @@ -341,7 +341,7 @@ // If oauth values aren't set, assumed that the user hasn't run setup yet. if ($auth == false) { - echo "Unable to send dm. You must run setup and authenticate first."; + echo "Unable show lists. You must run setup and authenticate first."; } else { @@ -382,7 +382,7 @@ // If oauth values aren't set, assumed that the user hasn't run setup yet. if ($auth == false) { - echo "Unable to send dm. You must run setup and authenticate first."; + echo "Unable to modify list. You must run setup and authenticate first."; } else { @@ -417,7 +417,7 @@ // If oauth values aren't set, assumed that the user hasn't run setup yet. if ($auth == false) { - echo "Unable to send dm. You must run setup and authenticate first."; + echo "Unable to modify list. You must run setup and authenticate first."; } else { From 17ab0bee742f5a2ae8ce803db98546a6a25e58ad Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 10:08:09 -0500 Subject: [PATCH 05/10] Removed dangling bracket! lol --- script.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.php b/script.php index fe29c34..fbaf9f6 100644 --- a/script.php +++ b/script.php @@ -359,7 +359,7 @@ else { $inc=1; foreach($res->results as $result): - echo "$result->slug\r\r"; } + echo "$result->slug\r\r"; $inc++; endforeach; } From 7621854d1da413ae6f684179084aa22ec0452f3d Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 10:09:33 -0500 Subject: [PATCH 06/10] Changed post to get for the lists command Twitter API request --- script.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.php b/script.php index fbaf9f6..433bd5e 100644 --- a/script.php +++ b/script.php @@ -352,7 +352,7 @@ $tweet = new TwitterOAuth($appkey1, $appkey2, $auth['oAuthKey'], $auth['oAuthSecret']); // add user to list - $res = $tweet->post('lists', array('screen_name' => $screen_name)); + $res = $tweet->get('lists', array('screen_name' => $screen_name)); //display result(s) if (isset($res->error)) { echo $res->error; } From 36231ca9bcf205ac7a5b413200d4abc9a8d7f85a Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 10:10:45 -0500 Subject: [PATCH 07/10] Removed inputs not needed for the lists command --- script.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/script.php b/script.php index 433bd5e..85df584 100644 --- a/script.php +++ b/script.php @@ -329,13 +329,6 @@ else if ($input[0] == "lists") { - $username = $input[1]; - $list = $input[2]; - unset($input[0]); - unset($input[1]); - unset($input[2]); - $message = implode(" ", $input); - // check authentication status $auth = check_auth(); From f2d2e6b4ff522f39c4b951109c2014eecbfe3f62 Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 15:43:06 -0500 Subject: [PATCH 08/10] Fixed the lists command loop to print the slug list names --- script.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script.php b/script.php index 85df584..827fc65 100644 --- a/script.php +++ b/script.php @@ -351,8 +351,9 @@ if (isset($res->error)) { echo $res->error; } else { $inc=1; - foreach($res->results as $result): - echo "$result->slug\r\r"; + foreach($res->lists as $list): + $slug = $list->slug; + echo "$slug\r"; $inc++; endforeach; } From 77dab5162af20623b9f50148a69ab332b46867d6 Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 16:22:41 -0500 Subject: [PATCH 09/10] Removed from unnecessary code copied from @jdfwarrior's examples --- script.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/script.php b/script.php index 827fc65..ea64925 100644 --- a/script.php +++ b/script.php @@ -366,10 +366,6 @@ $username = $input[1]; $list = $input[2]; - unset($input[0]); - unset($input[1]); - unset($input[2]); - $message = implode(" ", $input); // check authentication status $auth = check_auth(); @@ -401,11 +397,7 @@ $username = $input[1]; $list = $input[2]; - unset($input[0]); - unset($input[1]); - unset($input[2]); - $message = implode(" ", $input); - + // check authentication status $auth = check_auth(); From 35380b8e1eac3f3e17c4401ce6e6e8c3fe5622ae Mon Sep 17 00:00:00 2001 From: Mark Shropshire Date: Sat, 26 Nov 2011 16:24:37 -0500 Subject: [PATCH 10/10] Update help info concerning lists --- script.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.php b/script.php index ea64925..0f58fde 100644 --- a/script.php +++ b/script.php @@ -32,7 +32,7 @@ echo "tw block - Block user\r"; echo "tw unblock - Unblock user\r"; echo "tw search - Recent 5 matches\r\r"; - echo "Note on list related commands: List names must use hypens in place of spaces and special characters."; + echo "Note: List names must use hypens in place of spaces and special characters. Use 'tw list' to view your current lists."; } //end else ($auth is set) } //end else !$pin