Try instead:
curl_setopt ($ch, CURLOPT_POST, 1);

-Chad

On Thu, Mar 12, 2009 at 7:21 PM, benr <[email protected]> wrote:
>
> I'm trying to write a function that will follow a user via the API
> using PHP/curl. I believe I have setup correctly using curl to POST to
> twitter, but I keep getting the following error: "This method requires
> a POST.".  Here is my code:
>
> $url = 'http://twitter.com/friendships/create/'.urlencode
> ($id).'.json';
> $postargs = 'id='.urlencode($id);
>
> $ch = curl_init($url);
>
> curl_setopt ($ch, CURLOPT_POST, true);
> curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs);
> curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.$this-
>>password);
> curl_setopt($ch, CURLOPT_VERBOSE, 1);
> curl_setopt($ch, CURLOPT_NOBODY, 0);
> curl_setopt($ch, CURLOPT_HEADER, 0);
> curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
>
> $response = curl_exec($ch);
>
> $this->responseInfo=curl_getinfo($ch);
> curl_close($ch);
>
> All the values appear to be valid. I'm able to update my status using
> the above script (different url of course) and other actions, the only
> one I'm having trouble with right now is friendship/create.  Am I
> missing a CURL opt?

Reply via email to