Send a Tweet from your Medium One Account
Updated: May 16
This tutorial will show you how to send tweets from your Medium One account.
In this tutorial, you will:
Create a Twitter account
Tweet from Medium One
Here’s what you need to get started:
Medium One Prototyping Sandbox [Buy]
Step 1. Create a Twitter Account
If you don’t have a twitter account, create one on www.twitter.com.
Now you have a new twitter page. Keep this page open on the same laptop where you will login to your Medium One account. This allows us to link your Medium One account with your Twitter account, which we will do in the next step.
Step 2. Link your Twitter Account to Medium One
Login to your Medium One account.
In the left-hand menu, select External APIs, then click on Add New Service Key.
“Connect an External Service” will display. Select Service, then Twitter from the dropdown menu.
Click Save and Activate. You will see Twitter added as an external API.
Authorize Medium One to use your Twitter account. Click Authorize app.
Once authorized, your Medium One account will acknowledge that it is linked to your twitter account.
Step 3. Create a Workflow to Send a Tweet
If you do not have any users in your Medium One sandbox, then create at least one. Go to Manage Users (left-hand menu) and click Add New User. Create a user and save.
Let’s send a tweet at noon each day with the current weather for our location.
Click on the Workflow Studio icon and then click Create.
Select Tags & Triggers
Select Scheduler and drag the Daily module into the workflow.
Double click on Daily and select your user, set Schedule to 12:00pm, and set Timezone to your time zone. Click Save.
Add Code module:
Select Foundation and drag Base Python to the workflow editor window.
Connect Inputs to Code module:
Connect Daily to Base Python.
Replace the Base Python code
This code uses the pre-existing Module Library Weather.get_weather_by_coordinates(lat, lon). It gets the current weather at the latitude and longitude specified. We are using the latitude and longitude for Santa Clara, California. Note: You can change this to any city by googling that city’s latitude and longitude and replacing it in this code.
Double-click on the Base Python module and replace all code with the following:
import Twitter import Weather import json #Latitude and Longitude for Santa Clara, California lat = 37.426048 lon = -121.975243 weather = Weather.get_weather_by_<wbr />coordinates(lat, lon) #temperature in Kelvins temp_K = weather['main']['temp'] #temperature in Fahrenheit temp_F = (1.8 * (temp_K - 273)) + 32 log(temp_F) Twitter.post_status("The current temperature is "+ str(temp_F) +"F")
Your Base Python module should look like this:
Click Save and Activate.
At noon each day, you will tweet the current weather for Santa Clara, California.
Congratulations! You have successfully added Twitter to your Medium One account!
Want to learn more about what Medium One can do?