1
votes

POST /statuses/retweet is giving me this error while POST statuses/tweet and GET search/tweets are working fine.

public $host = "https://api.twitter.com/1.1/";

$con = $this->oauth();
$retweets = $con->post('statuses/retweet/', array('id' => $searchid));

The query will get the Status id_str of the object. It is in string format.

/**
* POST wrapper for oAuthRequest.
*/
function post($url, $parameters = array()) {
   $response = $this->oAuthRequest($url, 'POST', $parameters);
   if ($this->format === 'json' && $this->decode_json) {
      return json_decode($response);
   }
   return $response;
}

API console gives me no error:

https://api.twitter.com/1.1/statuses/retweet/{id}.json
2

2 Answers

1
votes

If you want to retweet the tweet with ID 1234 you need to send a POST request to

https://api.twitter.com/1.1/statuses/retweet/1234.json

It looks like you are trying to perform a GET request to

https://api.twitter.com/1.1/statuses/retweet/?id=1234
0
votes

figured it out. Retweet ID cant be sent as paramemeter. It has to be added as part of url. This is what i did. parameter to be null

$retweets = $con->post('statuses/retweet/'.$searchid, null);