下一页令牌R Google Places API

时间:2017-12-10 09:50:14

标签: r api google-api null googleway

我正在尝试从R中的Google Places API获取餐厅详细信息。我可以成功获得Google提供的20个结果但是我意识到,当它返回next_page_token时,这意味着还有其他结果(这是合乎逻辑的,我正在搜索的位置50公里半径范围内有超过20家餐厅。但是,当我使用next_page_token时,它会返回NULL。 这是我的代码:

install.packages("googleway")
library(googleway)

key <- 'my key'

df_places <- google_places(search_string = "restaurant", 
                       location = c(-33, 151),
                       page_token = "next_page_token",
                       radius = 50000,
                       key = key)
df_places$results$name
df_places$results$rating
df_places$results$formatted_address
df_places$results$geometry$location

以下是没有next_page_token的回复:

 [1] "Gennaro's Italian Restaurant"                   
 [2] "Mount Broke Wines & Restaurant"                 
 [3] "Oak Dairy Bar"                                  
 [4] "Bimbadgen"                                      
 [5] "Subway Restaurant"                              
 [6] "Muse Restaurant"                                
 [7] "Ocean Restaurant"                               

等...

以下是next_page_token返回的内容:

> df_places$results$name
NULL

只是想知道我反复返回NULL错误了什么?

1 个答案:

答案 0 :(得分:2)

要检查的第一件事是,您使用引用的字符串AllTasks,还是使用从结果到第"next_page_token"的第一个查询的对象next_page_token

以下是您的代码的工作示例

google_places()
相关问题