在尝试调整情感分析机器人时遇到了禁止错误。

huangapple go评论78阅读模式
英文:

Getting Forbidding error while trying to tweak a sentiment analyses bot

问题

抱歉,我只能翻译文本内容,以下是您提供的文本的翻译:

"So i was finding older versions of sentiment bots i could tweak and reuse and found this one from 9m ago but its giving me forbiddion error when i try to connect to twiiter api(error is below)
Forbidden: 403 Forbidden
453 - You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product

any idea on whats wrong?"

"所以我在寻找旧版本的情感机器人,以便进行调整和重用,我找到了这个来自9个月前的版本,但在尝试连接到Twitter API时出现了禁止错误(错误如下):
禁止:403 禁止
453 - 您当前只能访问Twitter API v2端点的子集和有限的v1.1端点(例如媒体发布、oauth)。如果您需要访问此端点,可能需要不同的访问级别。您可以在这里了解更多信息:https://developer.twitter.com/en/portal/product

有什么想法是什么问题?"

import os
import tweepy
from textblob import TextBlob

# 使用Twitter API进行身份验证
consumer_key = os.getenv('')
consumer_secret = os.getenv('')
access_token = os.getenv('')
access_token_secret = os.getenv('')

auth = tweepy.OAuthHandler('', '')
auth.set_access_token('', '')

api = tweepy.API(auth)

# 搜索与勇士队相关的推文
warriors_tweets = tweepy.Cursor(api.search_tweets, q='#GoldenStateWarriors', lang="en").items(1000)

# 对推文执行情感分析
positive_tweets = 0
negative_tweets = 0
neutral_tweets = 0

for tweet in warriors_tweets:
    analysis = TextBlob(tweet.text)
    if analysis.sentiment.polarity > 0:
        positive_tweets += 1
    elif analysis.sentiment.polarity < 0:
        negative_tweets += 1
    else:
        neutral_tweets += 1

# 打印结果
print("积极的推文", positive_tweets)
print("消极的推文", negative_tweets)
print("中性的推文", neutral_tweets)

我尝试管理Twitter API权限,但对API的使用了解有限。

英文:

So i was finding older versions of sentiment bots i could tweak and reuse and found this one from 9m ago but its giving me forbiddion error when i try to connect to twiiter api(error is below)
Forbidden: 403 Forbidden
453 - You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product

any idea on whats wrong?

import os
import tweepy
from textblob import TextBlob

# Authenticate with Twitter API
consumer_key = os.getenv('')
consumer_secret = os.getenv('')
access_token = os.getenv('')
access_token_secret = os.getenv('')

auth = tweepy.OAuthHandler('', '')
auth.set_access_token('', '')

api = tweepy.API(auth)

# Search for tweets about the Warriors
warriors_tweets = tweepy.Cursor(api.search_tweets, q='#GoldenStateWarriors', lang="en").items(1000)

# Perform sentiment analysis on tweets
positive_tweets = 0
negative_tweets = 0
neutral_tweets = 0

for tweet in warriors_tweets:
    analysis = TextBlob(tweet.text)
    if analysis.sentiment.polarity > 0:
        positive_tweets += 1
    elif analysis.sentiment.polarity < 0:
        negative_tweets += 1
    else:
        neutral_tweets += 1

# Print results
print("Positive tweets: ", positive_tweets)
print("Negative tweets: ", negative_tweets)
print("Neutral tweets: ", neutral_tweets)

i tried managing twitter api premssions but lack knowledge on the api usage

答案1

得分: 1

很遗憾,api.search_tweets在免费访问级别中不再可用。要使用它,您可以升级到基本访问级别。

英文:

Unfortunately, api.search_tweets is no longer available in the Free access level. To use it, you can upgrade to the Basic access level.

huangapple
  • 本文由 发表于 2023年6月2日 05:42:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76385905.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定