Post text and image

Tags: #twitter #ifttt #naas_drivers #snippet #content
Author: Jeremy Ravenel
Description: This notebook allows users to post text and images to their Twitter account.


Import libraries

import naas
import naas_drivers


Get data from yahoofinance

data = naas_drivers.yahoofinance.get("^FCHI", date_from=-200, moving_averages=[50, 20])
chart = naas_drivers.plotly.stock(data)
name = "chart.png"
naas_drivers.plotly.export(chart, name)
url = naas.assets.add(name, params={"inline": True})

Let's write the post

twitter_post = """📈🚀 Every day at 9AM PST / 6PM CET<br>
CAC40 index value with #MovingAverages 20 and 50
Don't miss an #opportunity to #invest<br>
PS : this post has been generated automatically with 😎
#automation #trading #data #analysis @Nasdaq
event = "twitter-post"
key = "ke4AigvXI5-EABaowdLt4fju1aOUxeMxSXQoN8FVyA"
data = {"value1": twitter_post, "value2": url}


Post data

result = naas_drivers.ifttt.webhook(event, key, data)