Twitter binding spec
Detailed documentation on the Twitter binding component
Setup Dapr component
The Twitter binding supports both input
and output
binding configuration. First the common part:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: bindings.twitter
version: v1
metadata:
- name: consumerKey
value: "****" # twitter api consumer key, required
- name: consumerSecret
value: "****" # twitter api consumer secret, required
- name: accessToken
value: "****" # twitter api access token, required
- name: accessSecret
value: "****" # twitter api access secret, required
Warning
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.
Input bindings
For input bindings, where the query matching Tweets are streamed to the user service, the above component has to also include a query:
- name: query
value: "dapr" # your search query, required
Output bindings
For output binding invocation the user code has to invoke the binding:
POST http://localhost:3500/v1.0/bindings/twitter
Where the payload is:
{
"data": "",
"metadata": {
"query": "twitter-query",
"lang": "optional-language-code",
"result": "valid-result-type"
},
"operation": "get"
}
The metadata parameters are:
query
- any valid Twitter query (e.g.dapr
ordapr AND serverless
). See Twitter docs for more details on advanced query formatslang
- (optional, default:en
) restricts result tweets to the given language using ISO 639-1 language coderesult
- (optional, default:recent
) specifies tweet query result type. Valid values include:mixed
- both popular and real time resultsrecent
- most recent resultspopular
- most popular results
You can see the example of the JSON data that Twitter binding returns here
Related links
- Bindings building block
- How-To: Trigger application with input binding
- How-To: Use bindings to interface with external resources
- Bindings API reference
Last modified February 16, 2021: Merge pull request #1235 from dapr/update-v0.11 (b4e9fbb)