本文整理汇总了Python中pattern.web.Twitter._authenticate方法的典型用法代码示例。如果您正苦于以下问题:Python Twitter._authenticate方法的具体用法?Python Twitter._authenticate怎么用?Python Twitter._authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pattern.web.Twitter
的用法示例。
在下文中一共展示了Twitter._authenticate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: URL
# 需要导入模块: from pattern.web import Twitter [as 别名]
# 或者: from pattern.web.Twitter import _authenticate [as 别名]
# Tip: we could create a bot that follows everyone,
# hope they follow us back, and then invent tweets that address them.
from pattern.web import URL, Twitter
# Tweet to post:
tweet = "avalancheddar"
# The API for posting is described here:
# # https://dev.twitter.com/rest/reference/post/statuses/update
url = URL("https://api.twitter.com/1.1/statuses/update.json", method="post", query={"status": tweet})
# We'll use the Twitter._authenticate() method to authenticate ourselves
# as @ccpattern (so the new tweet will appear on @ccpattern's page):
twitter = Twitter(license=ccpattern)
url = twitter._authenticate(url)
try:
# Send the post request.
url.open()
except Exception as e:
print e
print e.src
print e.src.read()
# To create your own Twitter bot:
# 1) You need a new e-mail address for the bot (e.g., gmail.com).
# 2) You need a new Twitter account.
# 3) Verify the Twitter account from the e-mail they send you.
# 4) Verify the Twitter account with a mobile phone number (this is mandatory):