I'm trying to send internal server notices via direct message to myself and another staff member through the API. I've gone through the API setup on dev.twitter and I've downloaded abraham's twitteroauth library.
Where do I need to be looking to send a message direct from the server (Through my account) without having to log in everytime with a browser? Last time I used the twitter API was before oauth, so quite some time has passed.
tl;dr Need to send direct messages through twitter without seeing this
Use Direct Messages to have non-public conversations on Twitter with anyone who follows you. You can check in with someone, start new conversations or move conversations off a timeline, or share Tweets or media with an individual or group. Your browser does not support the <code>video</code> element.
Use the navigation menu to go to Social Accounts > Edit Welcome DM and select your Twitter account. Here, you will find the form to enter your automated direct message and a checkbox to automatically send a welcome message.
Why am I having trouble sending Direct Messages? There is an account limit of 1,000 Direct Messages sent per day. Once you reach this limit, you can't send any more Direct Messages for the day. If you are sending Direct Messages to accounts that do not follow you, you may need to verify your phone number.
You can get your personal tokens from you app page on dev.twitter.com and use it without having to Sign in with Twitter
.
On your app page under the section OAuth settings
get:
And under Your access token
get:
Check that the access level is Read, write, and direct messages
. Otherwise change it in the Settings
tab and recreate your access tokens (there is a button on the bottom of the Details
tab).
Then in php
require('Abrahams library');
// Get everything you need from the dev.twitter.com/apps page
$consumer_key = 'APP KEY';
$consumer_secret = 'APP SECRET';
$oauth_token = 'YOUR TOKEN';
$oauth_token_secret = 'YOUR TOKEN SECRET';
// Initialize the connection
$connection = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
// Send a direct message
$options = array("screen_name" => "theGuyIWantToDM", "text" => "Hey that's my message");
$connection->post('direct_messages/new', $options);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With