I’ve created a Twitter developer account with my profile and passing cosumer_key, consumer_secret, token_id, and token_secret and If I’m hitting create-tweet 'https://api.twitter.com/1.1/statuses/update.json'
API then I’m getting a proper response but if I’m creating tweets with other users credentials I’m getting an error
([errors]=> Array([code] => 32, [message] => Could not authenticate you.))
. I’ve given read & write permission to my app as well.
public function createTweet(Request $req) {
Log::channel('twitterwebhook')->info($req->all());
$access_token = $req->require('token_id');
$acess_token_secret = $req->require('token_secret');
$message = $req->require('message');
$twitter = new TwitterAPI($access_token, $acess_token_secret);
$response = $twitter->createTweet($message);
if(isset($response->errors)){
return error($response->errors, 4099);
}
$data = [
'tweet_id'=> $response->id,
'tweet_str_id' =>$response->id_str,
'message' =>$response->text,
'user_twitter_id'=>$response->user->id,
'user_twitter_name'=>$response->user->name,
'user_twitter_screen_name'=>$response->user->screen_name
];
return success($data);
}
public function createTweet($tweet_message) {
$postfields = [
'status' => $tweet_message,
'trim_user' => false
];
$twitterResponse = $this->buildOauth($this->_update_url, 'POST')
->setPostfields($postfields)
->performRequest();
return json_decode($twitterResponse);
}