This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

ThingTweet App

Use the ThingTweet app to link a Twitter® account to your ThingSpeak™ account. Devices and channels can update via Twitter using the TweetControl API. For example, you can make a device tweet you when the temperature in your greenhouse drops or when the batteries in a device are running low.

Associate Twitter Account with ThingSpeak Account

If you are logged in to a Twitter account, ThingTweet automatically associates the available Twitter account to your ThingSpeak user account. Log out of Twitter to associate a different account.

  1. Sign In to ThingSpeak.

  2. Select Apps > ThingTweet.

  3. Click Link Twitter Account.

    You are redirected to Twitter. When asked to authorize ThingTweet to use your account:

    • Enter your Twitter username and password.

    • Click Authorize app.

  4. After you confirm the Twitter account, click the link Back to ThingTweet to return to the ThingTweet App page.

    Notice that your Twitter account is now linked to ThingSpeak

The app generates a ThingTweet API Key for you to use. Use this API key and a message to send a request to ThingTweet. The message gets relayed to Twitter. You can use all parameters of the Twitter API to send the message. See statuses / update in the Twitter documentation for more information. To view the ThingTweet API key for each ThingTweet app, select Apps > ThingTweet.

Update Twitter Status

To update your Twitter status with ThingTweet, send an HTTP POST with the ThingTweet API key and your status message.

TitleHTTP POST Request to Update Twitter Status
URLhttps://api.thingspeak.com/apps/thingtweet/1/statuses/update
HTTP MethodPOST
HTTP Header X-THINGSPEAKAPIKEY=XXXXXXXXXXXXXXX
Data Parametersapi_key=XXXXXXXXXXXXXXX
status=I just posted this from my thing!
Success Response 1
Error Responses–1
Sample HTTP CallPOST /apps/thingtweet/1/statuses/update
HTTP/1.1 Host: api.thingspeak.com
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

api_key=YOUR_THINGTWEET_API_KEY
status=I+just+posted+this+from+my+Thing!
NotesThingTweet API key must appear in either the HTTP header or in the body section, or it can appear in both

Example POSTMAN Request

You can use POSTMAN to try out your HTTP requests using the RESTful API for ThingSpeak. Select the Body of the request as x-www-form-urlencoded. Test the tweet request by configuring POSTMAN as shown.

Update Twitter Status with Last Value from Channel

You can include channel data in your Twitter message. ThingTweet replaces "%%channel_CHANNEL-ID_field_FIELD-NUMBER%%" with the last value of the specified channel and field. To update your Twitter status with the last value from Channel 1417, field1, send an HTTP POST.

TitleHTTP POST Request to Update Twitter status with Last Value from Channel Field
URLhttps://api.thingspeak.com/apps/thingtweet/1/statuses/update
HTTP MethodPOST
HTTP Header X-THINGSPEAKAPIKEY=XXXXXXXXXXXXXXX
Data Parametersapi_key=XXXXXXXXXXXXXXXX
status=The current CheerLights color is %%channel_1417_field_1%%
Success Response 1
Error Responses–1
Sample HTTP CallPOST /apps/thingtweet/1/statuses/update
HTTP/1.1 Host: api.thingspeak.com
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

api_key=YOUR_THINGTWEET_API_KEY
status=The+current+CheerLights+color+is+%25%25channel_1417_field_1%25%25
NotesThingTweet API key must appear in either the HTTP header or in the body section, or it can appear in both

Example POSTMAN Request

You can use POSTMAN to try out your HTTP requests using the RESTful API for ThingSpeak. Test the tweet request using POSTMAN and configuring as shown.

To update a channel and simultaneously post a tweet from your device, see Write Data.

Replacement Keys

You can pass data to your apps using replacement keys. The following table summarizes the standard and custom replacement keys you can use. Some keys are specific to a particular type of request, as indicated in the last column.

KeyDescriptionExampleUse With
%%YOUR_CUSTOM_LABEL%%ThingHTTP replaces this custom replacement value with data in the trigger request that has the label "YOUR_CUSTOM_LABEL".field1=%%YOUR_CUSTOM_LABEL%%
POST data: YOUR_CUSTOM_LABEL=1234.
RESULT: field1=1234.
Any request
%%channel_CHANNEL_ID_
field_FIELD_NUMBER%%
The last value of the specified channel and field. Replacement requests to private channels not owned by the same user as the ThingHTTP request return blank values.The latest value is %%channel_12_field_1%%.
RESULT: The latest value is 2.5.
Any request
%%datetime%%The full date and time when the TimeControl or React ran.The date and time the event occurred is %%datetime%%.
RESULT: The date and time the event occurred is 2014-09-24 5:32 p.m.
TimeControl or React
%%day%%The name of the weekday when TimeControl ran.The day the event occurred is %%day%%”.
RESULT: The day the event occurred is Wednesday.
TimeControl
%%day_index%% The zero-based index of the weekday starting on Sunday.the number of days used this week is %%day_index%%.
RESULT: The number of days used this week is 3.
TimeControl
%%hour%%The hour of the day when TimeControl ran.The hour that the event occurred is %%hour%%.
RESULT: The hour that the event occurred is 5.
TimeControl
%%minute%%The minute of the hour when the TimeControl ran.The minute the event occurred is%%minute%%.
RESULT: The minute the event occurred is 30.
TimeControl
%%trigger%%The value that triggered React.It is way too hot in here at %%trigger%% C.
RESULT: It is way too hot in here at 40 C.
React
%%channel_id%%The channel ID that triggered React.The channel that tweets is %%channel_id%%.
RESULT: The channel that tweets is 1256.
React

Related Topics