Abraham’s Twitteroauth with direct_messages/events/new

directmessages
php

#1

Hey everyone,
I have a question regarding twitteroauth. I’m successfully using the library to post a simple direct message

$options = array(‘screen_name’ => ‘*****’, ‘text’ => “test”);
$connection = new TwitterOAuth(CONS_KEY, CONS_SECRET, ACC_TOKEN, ACC_TOKEN_SECRET);
$result = $connection->post(‘direct_messages/new’, $options);

But I’m not able to use de library to send a post with a quick reply options (https://dev.twitter.com/rest/direct-messages/quick-replies/options), I have tried with different arrays and the result its always the same: null
Someone can help me and give an example of how to use it, please.
This is the last code I try:

$data = array(“sender_id” => $this->user[‘senderid’],
“text” => “Whats your favorite type of bird?”,
“quick_reply” => array(
“type”=> “options”,
“options”=> array(array(
“label”=> “Red Bird”,
“description” => “A description about the red bird.”,
“metadata”=> “external_id_1”
),
array(
“label”=> “White Bird”,
“description”=> “A description about the white bird.”,
“metadata”=> “external_id_4”
)
) )
);
$connection = new TwitterOAuth(CONS_KEY, CONS_SECRET, ACC_TOKEN, ACC_TOKEN_SECRET);
$result = $connection->post(‘direct_messages/events/new’, $data);

Thanks in advance


#2

There is an open PR to support POSTing JSON. It’s working but needs some cleanup and tests. I’m hoping to finish it up soon.


#3

Great, Thanks a lot!