Add a new member to a Twitter List
Posted
by yc10
on Stack Overflow
See other posts from Stack Overflow
or by yc10
Published on 2010-04-01T21:49:48Z
Indexed on
2010/04/01
21:53 UTC
Read the original article
Hit count: 247
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.
© Stack Overflow or respective owner