我在 Python 中收到了 Foursquare API 的关键错误消息

问题描述

我正在尝试使用 Foursquare API 来获取有关场地的信息。我使用下面的代码收到密钥错误消息。

rd

关键错误:'邻居'

我已经等了几天,以确保我没有超过我的限制并更改了版本并重置了客户端密码。我也尝试过创建一个新帐户,但仍然收到此错误消息。

这是数据框

def getNearbyVenues(names,latitudes,longitudes,radius=1000,LIMIT=100):
    
    venues_list=[]
    for name,lat,lng in zip(names,longitudes):
        print(name)
            
        # create the API request URL
        url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}'.format(
            CLIENT_ID,CLIENT_SECRET,VERSION,lng,radius,LIMIT)
            
        # make the GET request
        
        results = requests.get(url).json()['response'].get('groups',[{}])[0].get('items',[])
        
        # return only relevant information for each nearby venue
        venues_list.append([(
            name,v['venue']['name'],v['venue']['location']['lat'],v['venue']['location']['lng'],v['venue']['categories'][0]['name']) for v in results])

    nearby_venues = pd.DataFrame([item for venue_list in venues_list for item in venue_list])
    nearby_venues.columns = ['Neighborhood','Neighborhood Latitude','Neighborhood Longitude','Venue','Venue Latitude','Venue Longitude','Venue Category']
    
    return(nearby_venues)

toronto_venues=getNearbyVenues(names=df['Neighborhood'],latitudes=df['Latitude'],longitudes=df['Longitude'])
     Borough                Neighborhood            Latitude    Longitude
0   north York                           Parkwoods  43.753259   -79.329656
1   north York                    Victoria Village  43.725882   -79.315572
2   Downtown Toronto     Regent Park,Harbourfront  43.654260   -79.360636
3   north York     LaWrence Manor,LaWrence Heights 43.718518   -79.464763
4   Queen's Park      Ontario Provincial Government 43.662301   -79.389494

解决方法

我能够通过将代码重写到新笔记本中来解决该问题。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...