Twitter API – Creating lists with PHP and cURL
I needed to be able to create Twitter lists for my Tweet Large project. So, here is a method i made to do this. It is in PHP and requires the cURL library. Simply pass the new list name, as well as the username and password and the list will be created.
public function createList($listname='', $username='', $password=''){ if (!empty($listname) && !empty($username) && !empty($password)){ $url = 'http://api.twitter.com/1/'.$username.'/lists.xml'; $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "$url"); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "name=$listname"); curl_setopt($curl_handle, CURLOPT_USERPWD, $username.":".$password); $buffer = curl_exec($curl_handle); curl_close($curl_handle); } }



