hello, Can you share an php example code, i’m trying the below code but don’t work’s for me. Return’s error ““errors”:[{“code”:215,“message”:“Bad Authentication data.”}]”
$settings = array(
‘oauth_access_token’ => $channel->accessToken,
‘oauth_access_token_secret’ => $channel->accessTokenSecret,
‘consumer_key’ => $twApp->apiKey,
‘consumer_secret’ => $twApp->apiSecret
);
$twitter = new TwitterAPIExchange($settings);
$url = 'https://api.twitter.com/1.1/direct_messages/events/new.json';
$params = json_encode(array(
'event' => array(
'type' => 'message_create',
'message_create' => array(
'target' => array(
"recipient_id" => $this->fromUserId),
'message_data' => array(
'text' => $text
)
)
)
)
);
$requestMethod = 'POST';
echo $twitter->buildOauth($url, $requestMethod)
->performRequest(true,
array(CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
), CURLOPT_POSTFIELDS => $params)
);