Hi Sir
I am using the following code and library functions to use twitter API’s. have also checked the app permissions and it has permission to direct message send.
require "vendor/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$globalProjectName = "TweekSocial";
$consumerKey = 'vT********************RQy';
$consumerSecret = 'hdJqg*****************o************************MF0';
$accessToken = "8**********************************************a6I";
$accessSecret = "zYJ********************************************dRH";
$baseUrl = "http://******************/";
$redirectURL = 'http://******************/';
$data = [
'event' => [
'type' => 'message_create',
'message_create' => [
'target' => [
'recipient_id' => $userId
],
'message_data' => [
'text' => "hi new dm messg to ashsi "
]
]
]
];
$result = $connection->post('direct_messages/events/new ', $data, true); // Note the true
print_r("<br/> USER send direct mesage api <br/>");
var_dump($connection->getLastHttpCode());
It always return 400 and null
Please help me out how to run direct message event new API