Twitter retweet with curl

Discussion in 'PHP' started by Silver89, Jul 29, 2010.

  1. #1
    I'm trying to retweet with the twitter api: http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-retweet

    But I want to do the following command line as curl in php:

    curl -u user:password -X POST http://api.twitter.com/1/statuses/retweet/12345.xml
    Code (markup):
    At the moment I have the following which isn't working?

    
    $curl = curl_init("http://api.twitter.com/1/statuses/retweet/12345.xml");
    curl_setopt($curl, CURLOPT_USERPWD, "username:password");
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_TIMEOUT, 10);
    
    $xml = curl_exec($curl);
    curl_close($curl); 
    
    echo $xml;
    
    PHP:
    What am I doing wrong?
     
    Silver89, Jul 29, 2010 IP
  2. AnonymousUser

    AnonymousUser Peon

    Messages:
    593
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try removing USERPWD and put

    curl_setopt($curl, CURLOPT_POSTFIELDS, "username:password");
     
    AnonymousUser, Jul 30, 2010 IP
  3. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #3
    No luck with that, I know get:

    Could not authenticate you.
    Code (markup):
     
    Silver89, Jul 30, 2010 IP