sakdavong / openhab

Automatically exported from code.google.com/p/openhab
GNU General Public License v3.0
0 stars 0 forks source link

Implement Twitter Action #287

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
see http://twitter4j.org/en/code-examples.html for more information

Original issue reported on code.google.com by teichsta on 7 May 2013 at 8:40

GoogleCodeExporter commented 9 years ago
Hi - I just pushed a changed to my clone (benjones12-latitude) which includes a 
new 'Tweet' action (accessed by sendTweet('statusupdate').

The authentication is a bit tricky as Twitter enforces you to use the same 
request token when authenticating so it has to be done in one session. 
Therefore I have just added a Thread.wait() for 5 mins, checking for the 
existence of a 'twitter.pin' file in the openHAB app path (checks every 5s). 

So the order of events is;

1. Start openHAB and ensure some rule is going to try and send a tweet (this 
should probably be changed to attempt authentication on startup - with a config 
option to enable/disable tweeting)

2. Check the log for the authentication URL

3. Grant access to openHAB for your chosen Twitter account

4. Copy the generated authentication pin and put inside a file called 
'twitter.pin' in format 'pin=<pin>' (details in the log message)

5. Wait a few seconds and openHAB should pick up the temp pin file, 
authenticate the request and generate/save access tokens in \etc\twitter.token 
for reuse later.

6. Tweeting should now work...

Original comment by ben.jone...@gmail.com on 8 May 2013 at 6:54

GoogleCodeExporter commented 9 years ago
Just pushed a changed relating to 1. in my earlier comment. There is now a 
'tweet.enabled=true' flag that needs to be set in openhab.cfg. This will then 
kick off the authentication process on startup.

Original comment by ben.jone...@gmail.com on 8 May 2013 at 7:17

GoogleCodeExporter commented 9 years ago

Original comment by teichsta on 21 May 2013 at 9:43

GoogleCodeExporter commented 9 years ago

Original comment by teichsta on 22 May 2013 at 9:47

GoogleCodeExporter commented 9 years ago
merged TwitterAction into default (see 
http://code.google.com/p/openhab/source/detail?r=36c4c2c763bd4f7ffe675968667f76f
2afe189ff). Additionally added the sendDirectMessage method

Original comment by teichsta on 23 May 2013 at 3:14