English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
在Python中使用Tweet之前,我们必须遵循一些步骤。
단계1-首先,我们必须具有高音扬声器配置文件,然后必须将其与我们的手机号码一起添加。
首先转到-设置->添加电话->添加号码->确认->保存
我们必须遵循这些步骤。然后关闭所有文本通知。
단계2-设置一个新的应用程序
遵循-Twitter应用程序->创建新应用程序->保留回调URL为空->创建Twitter应用程序
然后显示消息“您的应用程序已创建。您查看并调整应用程序的设置”
단계3-默认情况下,tweet的访问权限为只读。要发送推文,需要写许可。
按照-权限选项卡->您的应用程序需要什么类型的访问权限?->选择读取和写入->更新设置
权限设置已成功更新。更改可能需要一些时间才能反映出来。
단계4-花一些时间来获取键和访问令牌
遵循-键和访问令牌选项卡
单击创建我的访问令牌
您的应用程序访问令牌已成功生成
그런 다음, 접근 토큰을 확인합니다./비밀-또한 읽거나 쓰기 권한이 있습니다.
단계5-마지막으로 installtweety 명령어는 pip install tweety입니다.
# -*- coding: utf-8 -*- """ Created on Wed Oct 17 06:00:58 2018 @author: Satyajit """ import tweepy # personal details my_consumer_key ="customer_key" my_consumer_secret ="secret_no" my_access_token ="token_no" my_access_token_secret ="secret_token" # authentication of consumer key and secret my_auth = tweepy.OAuthHandler(my_consumer_key, my_consumer_secret) # Authentication of access token and secret my_auth.set_access_token(my_access_token, my_access_token_secret) my_api = tweepy.API(my_auth) my_api.update_status(status=”Hi All Of my Friends !!!!”)
import tweepy # personal information my_consumer_key ="customer_key" my_consumer_secret ="secret_no" my_access_token ="token_no" my_access_token_secret ="secret_token" # Authentication my_auth = tweepy.OAuthHandler(my_consumer_key, my_consumer_secret) my_auth.set_access_token(my_access_token, my_access_token_secret) my_api = tweepy.API(my_auth) my_tweet ="tweet msg" my_image_path ="path of the image" # To attach the media file my_status = my_api.update_with_media(my_image_path, my_tweet) my_api.update_status(my_status = my_tweet)