简体   繁体   English

Oauth Python Twitter身份验证

[英]Oauth Python twitter auth

import oauth2 as oauth

key = "xxxxx"
secret = "xxxxx"

request_token_url = "https://api.twitter.com/oauth/request_token"

consumer = oauth.Consumer(key= key, secret= secret)
client = oauth.Client(consumer)

resp, content = client.request(request_token_url, "GET")

print content

Once i have executed this script it works fine but what would be the best way to deal with the output it gives me. 一旦我执行了这个脚本,它就可以正常工作,但是处理它给我的输出的最好方法是什么。

The output is something like "xxxxxxxx&yyyyyyyyyy&zzzzzzzzz" 输出类似于“ xxxxxxxx&yyyyyyyyy&zzzzzzzzz”

And i need to use the varaibles xxxx and yyyy how can i parse these and put them into variables? 我需要使用变量xxxx和yyyy,如何解析这些变量并将其放入变量中?

Thanks William 谢谢威廉

output = content.split('&')
x = output[0]
y = output[1]

also check out Tweepy for Python interaction with Twitter. 还可以查看Tweepy与Twitter的Python交互。 https://github.com/tweepy/tweepy https://github.com/tweepy/tweepy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM