Hello @abraham thanks for quick reply. So here below i’ve paste the code of mine.
// this is the function to favorite and unfavorite tweet
public function favoriteTwitterStatus($user_id,$status_id,$account_name,$str_favorite)
{
$connection= $this->getTwitterConnection($user_id,$account_name);
//$responce = $connection->post('favorites/create/'.$status_id);
try{
if($str_favorite == 'Favorite')
{
$responce = $this->postApiData('favorites/create/'.$status_id,'',$connection);
}
else
{
$responce = $this->postApiData('favorites/destroy/'.$status_id,'',$connection);
}
}
catch(Exception $e){
echo $message = $e->getMessage();
exit;
}
}
// this function will handle all post requests
// To post/update twitter data
public function postApiData($request,$params = array(),$connection)
{
if($params == null)
{
$data = $connection->post($request);
}
else
{
$data = $connection->post($request,$params);
}
// Need to check the error code for post method
if($data->errors['0']->code == '88' || $data->errors['0']->message == 'Rate limit exceeded')
{
throw new Exception( 'Sorry for the inconvenience,Please wait for minimum 15 mins. You exceeded the rate limit');
}
else
{
return $data;
}
}
// below is the host url
public $host = "https://api.twitter.com/1.1/";
have i made any mistake over here ?
Thanks