Skip to content

Instantly share code, notes, and snippets.

@yusuke
Created March 3, 2011 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yusuke/853156 to your computer and use it in GitHub Desktop.
Save yusuke/853156 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php
require "./tmhOAuth.php";
$twitter = new tmhOAuth(
array("consumer_key" => "consumerkey",
"consumer_secret" => "soncumersecret",
"user_token" => "user token",
"user_secret" => "user sercret"));
$twitter->request("GET", $twitter->url("1/account/verify_credentials"));
$screenName = json_decode($twitter->response["response"])->{"screen_name"};
$command = $_REQUEST["command"];
if (isset($command)) {
$id = htmlspecialchars($_REQUEST["id"]);
if ("add" == $command) {
$userId = htmlspecialchars($_REQUEST["user_id"]);
// add specifed user id to the list
$twitter->request("POST", $twitter->url("1/$screenName/" . $id . "/members")
, array("id" => $userId));
print "userId: $userId has been added to the list id: $id<br>";
} else if ("delete" == $command) {
$userId = htmlspecialchars($_REQUEST["user_id"]);
// remove specified user id from the list
// this code works fine
// $twitter->request("POST", $twitter->url("1/$screenName/" . $id . "/members")
// , array("id" => $userId, "_method" => "DELETE"));
$twitter->request("DELETE", $twitter->url("1/$screenName/" . $id . "/members")
, array("id" => $userId), "");
$twitter->pr($twitter->response["response"]);
print "userID: $userId has beren removed from the list id: $id<br>";
}
$twitter->request("GET", $twitter->url("1/$screenName/" . $id . "/members"));
$users = json_decode($twitter->response["response"])->{"users"};
print "Members of @$screenName 's lsit id $id:<br>";
foreach ($users as $user) {
print "<a href='./delete-issue.php?command=delete&user_id=" . $user->{"id"}
. "&id=" . $id . "'>delete member</a> @" . $user->{"screen_name"} . "<br>";
}
?><br>
<form action="./delete-issue.php" method="POST">
<input type="hidden" name="command" value="add"/>
<input type="hidden" name="id" value="<?=$id?>"/>
user id to be added:<input type="text" name="user_id"/><br>
<input type="submit" value="add to list"/>
</form>
<?php
} else {
$twitter->request("GET", $twitter->url("1/$screenName/lists"));
$lists = json_decode($twitter->response["response"])->{"lists"};
print "@" . $screenName . "'s list:<br>";
foreach ($lists as $list) {
print "<a href='./delete-issue.php?command=show_members&id=" . $list->{"id"} . "'>show members</a> " .
htmlspecialchars($list->{"name"} . " - " . $list->{"description"}) . "<br>";
}
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment