2017-07-17 76 views
0

我想通过marcelcaraciolo在foursquare包装器中运行代码,但我经常得到这个错误,任何人都可以帮我解决这个问题吗?ImportError:无法导入名称OAuthHandler Foursquare Python

AttributeError: 'module' Object has no attribute 'OAuthHandler' 

代码如下

import foursquare 

# == OAuth2 Authentication == 
# 
# This mode of authentication is the required one for Foursquare 

# The client id and client secret can be found on your application's Details 
# page located at https://foursquare.com/oauth/ 
client_id = "sasa" 
client_secret = "xyz" 
callback = '' 

auth = foursquare.OauthHandler(client_id, client_secret, callback) 

#First Redirect the user who wish to authenticate to. 
#It will be create the authorization url for your app 
auth_url = auth.get_authorization_url() 
print ('Please authorize: ' + auth_url) 

#If the user accepts, it will be redirected back 
#to your registered REDIRECT_URI. 
#It will give you a code as 
#https://YOUR_REGISTERED_REDIRECT_URI/?code=CODE 
code = raw_input('The code: ').strip() 

#Now your server will make a request for 
#the access token. You can save this 
#for future access for your app for this user 
access_token = auth.get_access_token(code) 
print ('Your access token is ' + access_token) 
+1

不确定,但我认为它是'OAuthHandler'。大写关系我的朋友! – JoshKopen

+0

@JoshKopen @JoshKopen谢谢你的回复,不会有任何帮助:( – Zack

+0

它仍然是一样的错误信息? – JoshKopen

回答

0
import pyfoursquare as foursquare 

foursquare eg

你有pyfoursquare

>>> dir(foursquare) 

,并检查是否已OAuthHandler上市?

相关问题