python-twitter 验证 Twitter用户名密码

Twitter 的 API 提供一个验证用户的接口,如果验证用户名密码成功,返回用户的Profile信息。python-twitter也提供了封装,下面是个使用的例子,

import simplejson
import twitter
 
USERNAME = 'xxxxxx'
PASSWORD = 'xxxxxx'
 
try:
    api = twitter.Api(username = USERNAME, password = PASSWORD)
    user = api.VerifyCredentials()
    print 'Verify Credentials Success: %s' % user.name
except:
    print 'Verify Credentials Error'

Tags: , ,

Leave a Reply

Name and Email Address are required fields. Your email will not be published or shared with third parties.