If you’ve been using Twitter’s API, chances are you’ve switched, or are considering switching, to use OAuth (read about the benefits here). The easiest way to do this is to use a third-party library to help you make the API calls – just make sure that it supports HTTP DELETE, which is used for deleting Twitter Lists and List members.

If your library doesn’t support the HTTP DELETE method (like the official PHP OAuth extension), you can still make a call by doing the following:

  • tell Twitter to use delete with a parameter called _method with the value DELETE (eg. _method=DELETE)
  • send the request using HTTP POST method

Here’s an example of doing this using the PHP OAuth extension

1
2
3
4
5
6
7
8
9
10
$client = new OAuth(MY_CONSUMER_KEY, MY_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1);
$client->setToken($userKey, $userSecret);
 
// ... set up the url and parameters for the call (eg. $url and $params)
$url = "http://api.twitter.com/1/..... .json";
$params = array("some_key"=>"someValue");
$params["_method"] = "DELETE";    // supply the _method param with a value of DELETE
 
$client->fetch($url, $params, OAUTH_HTTP_METHOD_POST);    // use POST
$result = json_decode($client->getLastResponse(), true);

leave a reply?