Twitter widget - local server

Do i need to change the startup command to add the properties file (similar to the configuration?)

Generated the access keys and added the file under the correct path but its still not picking it up (have restarted the service and server).

10:34:36.887 TRACE - Incoming TwitMessage{id=62, command=Tweet, length=14, body=‘Alarm is off!!’}
10:34:36.890 ERROR - Error sending twit for user xxx@xxx. Reason : OAuth consumer key/secret combination not supplied

in twitter4j.properties:

oauth.consumerKey=xXXkBLxxxxxxxxxxxxxxx
oauth.consumerSecret=xxxJcgxxxxxxGxfxxxx7Hj3xxxxxxxxxxxxxxxxxxx

Updated to jar v0.17.0 but still getting the same message, have also tried putting the properties file under the data folder, and reloaded the widget on the dashboard.

Please show me how do you run server

In /etc/rc.local

/usr/bin/java -jar /home/pi/blynk/server-0.17.0.jar -dataFolder /home/pi/blynk/data -serverConfig /home/pi/blynk/server.properties &

Just for experiment please try to put twitter4j in /usr/bin

copied to /usr/bin but has the same result.

I deleted blynk.log and restarted and have gone through it from the start when it loads but there are no additional errors relating to twitter4j

Right, so after putting the file into “/” it now seems to be parsing it ok (I’ve replaced a few characters with xxx for security) :

23:51:18.586 DEBUG - oAuthConsumerKey: xTkBLxxxxxxxxxxxxkcPD
23:51:18.590 DEBUG - oAuthConsumerSecret: **************************************************
23:51:18.590 DEBUG - oAuthAccessToken: x22x4601-4GyZhtsxxxxxxxxxxxxxxxk92O
23:51:18.592 DEBUG - oAuthAccessTokenSecret: *********************************************
23:51:18.592 DEBUG - oAuth2TokenType: null
23:51:18.593 DEBUG - oAuth2AccessToken: null
23:51:18.593 DEBUG - oAuth2Scope: null
23:51:18.593 DEBUG - oAuthRequestTokenURL: https://api.twitter.com/oauth/request_token
23:51:18.594 DEBUG - oAuthAuthorizationURL: https://api.twitter.com/oauth/authorize
23:51:18.594 DEBUG - oAuthAccessTokenURL: https://api.twitter.com/oauth/access_token
23:51:18.595 DEBUG - oAuthAuthenticationURL: https://api.twitter.com/oauth/authenticate
23:51:18.596 DEBUG - oAuth2TokenURL: https://api.twitter.com/oauth2/token
23:51:18.596 DEBUG - oAuth2InvalidateTokenURL: https://api.twitter.com/oauth2/invalidate_token
23:51:18.597 DEBUG - restBaseURL: https://api.twitter.com/1.1/
23:51:18.597 DEBUG - streamBaseURL: https://stream.twitter.com/1.1/
23:51:18.598 DEBUG - userStreamBaseURL: https://userstream.twitter.com/1.1/
23:51:18.598 DEBUG - siteStreamBaseURL: https://sitestream.twitter.com/1.1/
23:51:18.599 DEBUG - uploadBaseURL: https://upload.twitter.com/1.1/
23:51:18.599 DEBUG - dispatcherImpl: twitter4j.DispatcherImpl
23:51:18.600 DEBUG - asyncNumThreads: 1
23:51:18.600 DEBUG - loggerFactory: null

But the error is different now (I have triple checked the keys - I have tried both the widgets Access token as well as the token generated on the Twitter Dev console)

23:52:11.880 TRACE - Incoming TwitMessage{id=2126, command=Tweet, length=14, body=‘Alarm On’}
23:52:11.940 DEBUG - Request:
23:52:11.940 DEBUG - POST https://api.twitter.com/1.1/statuses/update.json
23:52:11.947 DEBUG - OAuth base string: POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fupdate.json&include_entities%3Dtrue%26oauth_consumer_key%3xxxkBLMSMQxxxx99TzxxPD%26oauth_nonce%3D1xxx533xx44%26oauth_signature_method%xxxHMA$
23:52:11.960 DEBUG - OAuth signature: RVItnzxxxxxxT9Srcxxp+/EU=
23:52:11.966 DEBUG - Authorization: ********************************************************************************************************************************************************************************************************$
23:52:11.967 DEBUG - X-Twitter-Client-Version: 4.0.2
23:52:11.967 DEBUG - X-Twitter-Client-URL: http://twitter4j.org/en/twitter4j-4.0.2.xml
23:52:11.967 DEBUG - X-Twitter-Client: Twitter4J
23:52:11.967 DEBUG - User-Agent: twitter4j http://twitter4j.org/ /4.0.2
23:52:11.967 DEBUG - Accept-Encoding: gzip
23:52:11.968 DEBUG - Post Params: status=Alarm%20On&include_entities=true
23:52:19.018 DEBUG - Response:
23:52:19.020 DEBUG - date: Mon, 22 Aug 2016 21:52:18 GMT
23:52:19.021 DEBUG - HTTP/1.1 401 Authorization Required
23:52:19.021 DEBUG - set-cookie: guest_id=v1%3A147xxxx83703345; Domain=.twitter.com; Path=/; Expires=Wed, 22-Aug-2018 21:52:18 UTC
23:52:19.022 DEBUG - server: tsa_f
23:52:19.022 DEBUG - content-length: 89
23:52:19.022 DEBUG - x-tsa-request-body-time: 3
23:52:19.023 DEBUG - x-response-time: 96
23:52:19.023 DEBUG - x-connection-hash: d9b1xxxx6b409xxxxx8b79xxxx0cc
23:52:19.023 DEBUG - content-encoding: gzip
23:52:19.024 DEBUG - content-type: application/json; charset=utf-8
23:52:19.024 DEBUG - strict-transport-security: max-age=631138519
23:52:19.359 DEBUG - {“errors”:[{“code”:32,“message”:“Could not authenticate you.”}]}

23:52:19.396 ERROR - Error sending twit for user xxx@xxx. Reason : 401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access tok$
message - Could not authenticate you.
code - 32

I checked code. Enabling twits on local server requires also app changes (app_key and secret code). So this is impossible at the moment for local server. Sorry for confusion.

I would recommend you to use email + IFTTT.

Ah man, so close, :slight_smile:

Thanks Dimitriy, appreciate the feedback, I really should just move to Android.

I’ll keep working on it and see if i can get it to work, it appears to be close to working, might be able to find a workaround.

Is this iOS AND Android?

I’ve tried to add the application access token and secret generated from the developer dash into the .properties file with the consumer key details but it is still giving the same error.

I suspect if we can use the manually generated application token we may not need the widget on the dashboard directly (currently a $0 widget anyway)

Will revert back if i manage to get something to change.

I ran the test OAuth from the dashboard and copied the curl command into my local server which worked 100%, so I’m sure there is not a connectivity / port issue and the tokens are all functioning.

Alternately I will need to revert back to node.js to tweet (node.js webserver currently running to allow another device to send commands to the devices anyway)

On both…

For the interim I have created a node.js client that is subscribed the same MQTT topic as Blynk and then fires off the tweet directly if that payload.

Basically I now have the LED widget turn on in the Blynk Dashboard and the tweet that gets sent.

One other nice to have would be a RGB LED Widget that we could use to have multi-state status - e.g. Red for “On” and Green for “Ready”

Will be released in few days.

I’ve followed a similar path to @Bobbo_SA by using node-red functionality for tweeting (and sending notifications to my Pebble :slight_smile: ).

Having said that, the idea for a multi-state LED is pretty cool (I assume it’d involve making the color property settable at runtime). I could sure find a use for that widget! :smiley:

I really can’t say enough good things about Blynk. It’s awesome.

Could not agree more with your last statement, it has a few limitations (mostly sue to external factors, iOS and its controls being the main one) but then my implementation is not exactly standard either so I’m happy to find alternates to resolve the small constraints.

My Pi currently runs Blynk for main mobile interface, MQTT for inter network communications (Bridge became too much 15 devices i currently have deployed) and more recently Node.js for a Websockets API that publishes to certain MQTT topics and now another Node.js for Tweeting.

Similar setup, but I haven’t (yet) used MQTT. I think I’ll have to look into that. I have a feeling it will solve some things I’m struggling with right now. :slight_smile:

@pathway done. please check New Android Release 1.14.0

Hey, thanks @Dmitriy.

Looks good, but I’m unfortunately on iOS. I’ll see if I can get my hands on an Android device in the meantime.

@pathway free Android “device” here.

Let me know if you want me to share my node.js “work around”.