Why? BECAUSE WE CAN!!1!ioneoneeleven11!1
On a more serious note, there are legit uses for this - for example, posting "Our site is back online!" message. The biggest benefit is encouraging people to think outside of the box though.
Patch coming.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | twitter-n1890926-28-6.x-5.x.patch | 6.51 KB | damienmckenna |
| #27 | twitter-n1890926-27-7.x-6.x.patch | 8.83 KB | damienmckenna |
| #26 | twitter-n1890926-26-7.x-5.x.patch | 8.83 KB | damienmckenna |
| #20 | twitter-n1890926-20-6.x-5.x.patch | 3.11 KB | damienmckenna |
| #19 | twitter-n1890926-19-7.x-6.x.patch | 3.1 KB | damienmckenna |
Comments
Comment #1
Drave Robber commentedPatch attached.
Notes:
twitter_set_status()does not check whether the application has read access; if that's possible at all, probably it should, but this is outside of scope of this issue;grabbing the first authenticated account indecided to check ourselves whether at least one account exists - see #3twitter_connect()could probably be a bit more robust, but this is outside of scope again.Comment #2
Drave Robber commentedTo grab the first authenticated account, we need, well, at least one authenticated account to be added. This is something we can and should check for.
Comment #3
Drave Robber commentedAnother attempt.
This time, we check ourselves whether at least one authenticated account exists and bail out if there's not.
Application having only read access can still result in mysterious errors.
Comment #4
webchickI'm not exactly sure where to put this, but here's the set of instructions I needed to follow to get this working, which weren't really clear at the beginning:
0) Create an app at https://dev.twitter.com/apps. Yes, you need an entire "app" even though you're setting up a dumb site you're doing just purely to post to Twitter from Drush. ;)
1) Download Twitter and OAuth modules.
2) Enable the Twitter post module.
3) Go to admin/config/services/twitter/settings. Enter the "Consumer key" and "Consumer secret" values from https://dev.twitter.com/apps/YOUR-APP-ID/oauth
4) Take note of the "Callback URL" on that same page. Go to https://dev.twitter.com/apps/YOUR-APP-ID/settings and fill it in under "Callback URL." NOTE Drave Robber said that this should work from a localhost URL, but that was not the case for me. I had to put my site on a publicly-accessible URL for it to accept the value.
5) Also set your Application type access to "Read and write" on Twitter's app settings page.
6) Go back to Drupal and go to admin/config/services/twitter. Click the button there to authenticate.
7) This will redirect you to Twitter, click the "Authorize this app" button.
8) This will redirect you back to Drupal, and you should see your account details in the table there.
Now posting to Twitter from Drush should work. Hooray! :D
Comment #5
webchickSpecifically, it works like this. :)
Comment #6
webchickOne idea as a possible expansion to this would be to allow you to specify which account to post as. For example:
That might work around the replication of twitter_connect() too, I'm not sure.
Comment #7
Drave Robber commentedGood point. It could work like
drush cc- if called without an argument, it presents you a list of caches that can be cleared. Along the same lines,drush tweet 'some text'would present a list of available accounts.That 'grab the first authenticated account' thing looked shoddy to me from the start.
Comment #8
webchickYeah, that's a great idea! Even better if it's smart enough to auto-select the first choice if there's only one available. :D Which I believe Drush handles already? (Maybe not.)
Comment #9
Drave Robber commentedBigger and better version attached.
drush tweet "New stuff available for Spark!" sparkdrupalComment #10
Drave Robber commentedNeed to make sure the length of the tweet does not exceed 140 chars, or it would crash with a giant
suckingscreeching sound.Interdiff is #10 against #9.
On a side note, Twitter also does not allow posting the same text two times in a row; to check for that, however, we would need to refresh timeline before posting, and that would make the whole thing even slower than it already is.
Comment #11
juampynr commentedThanks for the work you put into this. I apologize I could not give feedback earlier but I will look into it soon.
Comment #12
13rac1 commentedFYI #10 applies cleanly.
Comment #13
jibranCommit it please. It is a cool feature.
Comment #14
damienmckennaTriggering the testbot.
Comment #15
damienmckennaTriggering the testbot.
Comment #17
damienmckennaComment #18
damienmckennaSome minor updates.
Comment #19
damienmckennaPorted to 7.x-6.x.
Comment #20
damienmckennaPorted to 6.x-5.x.
Comment #22
damienmckennaCommitted.
Comment #25
damienmckennaWhoops - just discovered a bug in the logic for selecting the account that's used to send the tweet. An update is on its way.
Comment #26
damienmckennaThis should resolve the problem.
Comment #27
damienmckennaPorted to 7.x-6.x.
Comment #28
damienmckennaPorted to 6.x-5.x.
Comment #33
damienmckennaCommitted.