E
E
Eugene Ordinary2017-10-12 17:04:33
PHP
Eugene Ordinary, 2017-10-12 17:04:33

How to send a private message on Twitter using CURL?

I set the parameters via CURLOPT_POSTFIELDS:
$param_arr = array(
'screen_name' => $recipient_screen_name,
'text' => $text,
'oauth_access_token' => $oauth_access_token // 111111111-XxXxXxXxXxXxXxXxXxXxXxXxXxXx
);
and send
$ch = curl_init($url); // url = https://api.twitter.com/1.1/direct_messages/new.json
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $param_arr );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$curl_res = curl_exec($ch);
$curl_err = curl_errno($ch);
curl_close($ch);
In response:
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
What other parameters are needed for authorization?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question