Created
March 3, 2011 17:38
-
-
Save yusuke/853156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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