Add a new member to a Twitter List
- by yc10
I'm trying to add a user (by variable $id) to a Twitter List using PHP CURL, and I can't get it to work.
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "http://twitter.com/username/list/members.xml");
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "id=$id");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERPWD, "username:password");
curl_setopt($curl_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl_handle, CURLOPT_VERBOSE, 1);
$result = curl_exec($curl_handle);
// Look at the returned header
$resultArray = curl_getinfo($curl_handle);
curl_close($curl_handle);
if($resultArray['http_code'] == "200"){
echo 'Success';
} else {
echo var_dump($resultArray);
}
The var_dump reveals that the http_code of the return is 403.