【问题标题】:Can i use twitter api for select poll votes ? is there any methods in tweepy?我可以使用 twitter api 进行选择投票吗? tweepy有什么方法吗?
【发布时间】:2019-08-22 11:13:07
【问题描述】:

我想使用 twitter api 使用 tweepy 进行投票,有什么方法可以实现吗?

我尝试过api.update_status("poll_1"[1112227775552223333]),但它不起作用。

【问题讨论】:

  • 没有用于与 Twitter 民意调查交互的 API。

标签: python-3.x api twitter automation tweepy


【解决方案1】:

没有。投票 API 是私有的,除 Twitter 自己的应用程序外,任何人都无法使用。

没有计划向公众开放 - https://twittercommunity.com/t/poll-support/78235

【讨论】:

    【解决方案2】:

    另一个答案不正确。有一种方法,只是您返回的 JSON 数据非常笨拙(我计划构建一个 tweepy 插件以使这更容易)。使用 Python 3.x 获取它的方法是通过requests。不过不用担心,这只是一行左右的代码。正如你在link 中看到的那样,我们确实可以取回 Twitter 民意调查数据。这是一个代码sn-p:

    import requests, json, OAuth1
    
    # provided by a Twitter dev account
    auth = OAuth1(my_key, my_secret_key, my_access_token, my_secret_access_token) 
    
    tweet_ids_string = "12345678,123456790,09886654333"
    
    # for more expansions see the link above
    data_url = f'https://api.twitter.com/2/tweets?ids={tweet_ids_string}&expansions=attachments.poll_ids&poll.fields=duration_minutes,end_datetime,options,voting_status' 
    
                               
    response = requests.get(get_data_url, auth=auth)
    response_json = response.json() # then you can get all sorts of data from here
    

    但请注意,Twitter 投票 API 的速度并不快,因此在投票通过投票和请求 JSON 更改之间可能会有几秒钟的延迟。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多