Example of how to use Twitter search input component in godapr.
To run this demo locally, you will have to have install dapr. The instructions for how to do that can be found here.
To configure the dapr input component to query Twitter API you will also need the consumer key and secret. You can get these by registering a Twitter application here.
Assuming you have all the prerequisites mentioned above you can demo this dapr pipeline in following steps. First, start by cloning this repo:
git clone https://github.com/mchmarny/twitter-search-dapr-component-example.git
and then navigate into the twitter-search-dapr-component-example
directory:
cd twitter-search-dapr-component-example
Insert your Twitter API secrets into the components/twitter.yaml file.
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: tweets
spec:
type: bindings.twitter
metadata:
- name: consumerKey
value: ""
- name: consumerSecret
value: ""
- name: accessToken
value: ""
- name: accessSecret
value: ""
- name: query
value: "serverless"
The query
is the twitter search query for which you want to receive tweets.
Once the Twitter API consumer and access details are set, you are ready to run:
dapr run go run handler.go main.go \
--app-id "consumer" \
--app-port 8081 \
--protocol http \
--port 3500
Assuming everything went OK, you should see something like this:
ℹ️ Updating metadata for app command: handler.go main.go
✅ You're up and running! Both Dapr and your app logs will appear here.
Hope you found this demo helpful.
This is my personal project and it does not represent my employer. I take no responsibility for issues caused by this code. I do my best to ensure that everything works, but if something goes wrong, my apologies is all you will get.
This software is released under the Apache v2 License