React or ThingHttp to send tweet or all? | ThingSpeak Apps | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
React or ThingHttp to send tweet or all?
No permission to create posts
September 25, 2015
4:20 pm
Avatar
patman
New Member
Members
Forum Posts: 2
Member Since:
September 25, 2015
sp_UserOfflineSmall Offline

I'm trying to send a tweet when certain conditions are met in the data in my feed. However I'm stymied by the fact that Twitter will only show a given Tweet once. React works well to send a tweet but if it sends it twice I only see the first one on Twitter. Variables such as %%Date%% will not work in a React.

Can anyone help?

Thanks

September 25, 2015
4:59 pm
Avatar
lee

Admin
Forum Posts: 457
Member Since:
March 14, 2011
sp_UserOfflineSmall Offline

Hi,

If you use %%trigger%% in your React, does that help to avoid sending the same tweet?
https://thingspeak.com/docs/react#replacements

lee

September 25, 2015
7:17 pm
Avatar
patman
New Member
Members
Forum Posts: 2
Member Since:
September 25, 2015
sp_UserOfflineSmall Offline

I tried that but the data doesn't change enough, it's an on/off switch.

September 29, 2015
7:54 pm
Avatar
rw950431

Top
Members
Forum Posts: 269
Member Since:
January 30, 2014
sp_UserOfflineSmall Offline

Perhaps this will work for you?

1. Set up your thingTweet and get the key.
2. Create a Matlab analysis with the code shown below, adding your channel ID, read api key and thingTweet key where shown.
3. Set up a React that triggers your matlab analysis.

You can customize the message by changing fmtstr

% add timestamp to data in order to bypass twitters 'no duplicates' policy

% TODO - Replace the [] with channel ID to read data from:
readChannelID = [YOUR_CHANNEL_ID];
% TODO - Enter the Read API Key between the '' below:
readAPIKey = 'YOUR_READ_KEY';

%% Read Data for field 1 of given channel %%
data = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey, 'Fields',1);
%% uncomment below to debug data
% disp(data)
thingTweetURL = 'https://api.thingspeak.com/apps/thingtweet/1/statuses/update';
thingTweetApiKey = 'YOUR_THINGTWEET_KEY';
fieldName = 'status';
fmtstr='Sensor reading %0.1f at %s';
fieldValue = sprintf(fmtstr,data,datestr(datetime('now')));
response = webwrite(thingTweetURL,'api_key',thingTweetApiKey,fieldName,fieldValue)

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
23 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

dollyip18, toddbt2, SatrapB, Ronalpsync, wandaim69, GregoryGof

Administrators: Hans: 387, lee: 457