twitter: Not able to set param for direct message
Hello There,
I have integrated this in my web app and now wants to use direct message but I am able to send because getting error.
Array to string conversion
so it means either I am using and sending parameters wrong in postDm method or something need to change in tmhOAuth.php which we are using for sending request.
Please let me know how I can create params and can use direct message apis.
Here is the code sample which I am following ->
$twitterConfigs=[
'consumer_key' => 'my_consumer_key',
'consumer_secret' => 'my_consumer_secret',
'token' => 'my_oauth_token',
'secret' => 'my_oauth_token_secret',
];
Twitter::reconfig($twitterConfigs);
$recipient_id = 1234567890;
$pm_mesaage = urlencode('Hello World');
$params = ['type'=>'message_create',
'message_create' => [
'target' => ['recipient_id' => $recipient_id],
'message_data' => ["text" => $pm_mesaage]
]
];
try
{
$response = Twitter::postDm($params);
print_r($response);
}
catch (\Exception $e)
{
$errors = Twitter::error();
print_r($errors);
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 22 (11 by maintainers)
Should be fixed now, thanks @reliq 😄
@sykezz thanks (I have now used version 2.2.14 as its been released) @reliq thanks - although I did have to do “composer config minimum-stability dev” to install the latest thujohn/twitter … (I’m no expert) but I think it needs a dev version of atymic/tmhoauth I’m happy as I can now send a DM !! Thanks all.
Awesome job @reliq! 🎉
This has been fixed with version 2.2.14.
Sample usage:
@andywise0 You can change your composer.json to load the package from Github from the PR branch if you want. Or you can pull the package to local (packages directory) and then load it, so you could switch branches and do changes easily.
@andywise0 I believe he tried https://github.com/atymic/tmhOAuth/pull/3.
@sykezz I tried that and it works perfectly.