小编Cha*_*ere的帖子

使用Twitter API-如何使用承载令牌获得参与端点的身份验证

我正在尝试获取公司在市场营销仪表板上的推文的参与度数据。我可以通过Tweepy进行身份验证,以获取基本的Twitter feed数据,但是参与端点给我带来了麻烦。我是否有可能先通过Tweepy进行身份验证,然后再使用不记名令牌来弄乱事情?

import tweepy
import requests
import json
import base64
import urllib.parse

consumer_key = <>
consumer_secret = <>
access_token = <>
access_token_secret = <>


auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

print(api.me().name)


def get_tweet_ids():
    scandy_tweets = api.user_timeline('TwitterHandle', count=5)
    tweet_id_list = []
    for twit in scandy_tweets:
        json_str = json.loads(json.dumps(twit._json))
        tweet_id_list.append(json_str['id'])
    return tweet_id_list


def get_bearer_token():
    uri_token_endpoint = 'https://api.twitter.com/oauth2/token'
    key_secret = f"{consumer_key}:{consumer_secret}".encode('ascii')
    b64_encoded_key = base64.b64encode(key_secret)
    b64_encoded_key = b64_encoded_key.decode('ascii')

    auth_headers = {
        'Authorization': 'Basic {}'.format(b64_encoded_key),
        'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
        }

    auth_data = {
        'grant_type': …
Run Code Online (Sandbox Code Playgroud)

python authentication api twitter

5
推荐指数
1
解决办法
44
查看次数

当我使用 rustc 编译时,为什么会出现在 Cargo.toml 中列为依赖项的“找不到板条箱”?

我的 Cargo.toml 包括:

[dependencies]
chrono = "0.4"
Run Code Online (Sandbox Code Playgroud)

我的代码包括:

extern crate chrono;
use chrono::{Duration, DateTime, Utc};
Run Code Online (Sandbox Code Playgroud)

但是当我运行我的代码时,我收到了这个错误:

[dependencies]
chrono = "0.4"
Run Code Online (Sandbox Code Playgroud)

我正在做一个锻炼练习,所以我构建/运行程序的方式是rustc src/lib.rs测试我的解决方案。问题是因为我没有跑步rustc src/main.rs吗?

rust rust-cargo

2
推荐指数
1
解决办法
534
查看次数

标签 统计

api ×1

authentication ×1

python ×1

rust ×1

rust-cargo ×1

twitter ×1