如何解决 Twitter 搜索中的运算符错误 API 2.0
How to solve operator error on Twitter search API 2.0
我已经阅读了新版Twitter搜索API2.0的完整文档,用于实现Premium搜索API版本。目前,我正在使用 python 从 Twitter 获取推文,我正在使用 searchtweets 库来实现它。我已经在我的开发者门户中设置了高级搜索的免费层 API。
问题 - 当我尝试获取基于 $CASHTAGS(如 $AMZN)的推文时,它说不允许使用 $CASHTAGS,但根据文档,我可以使用 $CASHTAGS 过滤。
我的代码-
account_type = 'premium'
endpoint = 'https://api.twitter.com/1.1/tweets/search/fullarchive/development.json'
from searchtweets import gen_rule_payload
from searchtweets import ResultStream
query = '($AMZN)'
rule = gen_rule_payload(query, results_per_call=100, from_date="2021-02-01", to_date="2021-02-10")
rs = ResultStream(rule_payload=rule,
max_results=3000,
**premium_search_args)
for tweet in rs.stream():
print(tweet)
错误-
HTTP Error code: 422: {"error":{"message":"There were errors processing your request:
Reference to invalid operator 'cashtag'. Operator is not available in current product or product packaging.}}
根据您的端点,您正在使用 Twitter API 1.1
endpoint='https://api.twitter.com/1.1/tweets/search/fullarchive/development.json'
.
如果您参考 Twitter API 2.0 版,自 2021 年 6 月 1 日起,现金标签仅适用于学术研究产品轨道。
我已经阅读了新版Twitter搜索API2.0的完整文档,用于实现Premium搜索API版本。目前,我正在使用 python 从 Twitter 获取推文,我正在使用 searchtweets 库来实现它。我已经在我的开发者门户中设置了高级搜索的免费层 API。
问题 - 当我尝试获取基于 $CASHTAGS(如 $AMZN)的推文时,它说不允许使用 $CASHTAGS,但根据文档,我可以使用 $CASHTAGS 过滤。
我的代码-
account_type = 'premium'
endpoint = 'https://api.twitter.com/1.1/tweets/search/fullarchive/development.json'
from searchtweets import gen_rule_payload
from searchtweets import ResultStream
query = '($AMZN)'
rule = gen_rule_payload(query, results_per_call=100, from_date="2021-02-01", to_date="2021-02-10")
rs = ResultStream(rule_payload=rule,
max_results=3000,
**premium_search_args)
for tweet in rs.stream():
print(tweet)
错误-
HTTP Error code: 422: {"error":{"message":"There were errors processing your request:
Reference to invalid operator 'cashtag'. Operator is not available in current product or product packaging.}}
根据您的端点,您正在使用 Twitter API 1.1
endpoint='https://api.twitter.com/1.1/tweets/search/fullarchive/development.json'
.
如果您参考 Twitter API 2.0 版,自 2021 年 6 月 1 日起,现金标签仅适用于学术研究产品轨道。