The documentation you are viewing is for Dapr v1.5 which is an older version of Dapr. For up-to-date documentation, see the latest version.
Twitter binding spec
Detailed documentation on the Twitter binding component
配置
To setup Twitter binding create a component of type bindings.twitter
. 请参阅本指南,了解如何创建和应用绑定配置。
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
以上示例将密钥明文存储, 更推荐的方式是使用 Secret 组件, 这里。元数据字段规范
字段 | 必填 | 绑定支持 | 详情 | 示例 |
---|---|---|---|---|
consumerKey | Y | Input/Output | Twitter API consumer key | "conusmerkey" |
consumerSecret | Y | Input/Output | Twitter API consumer secret | "conusmersecret" |
accessToken | Y | Input/Output | Twitter API access token | "accesstoken" |
accessSecret | Y | Input/Output | Twitter API access secret | "accesssecret" |
绑定支持
此组件支持 输入和输出 绑定接口。
字段名为 ttlInSeconds
。
get
输入绑定
For input binding, 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
输出绑定
get
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
相关链接
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.