ruby - 如何使用 rest-client 从 Waze 获取 GPS 数据?

标签 ruby rest-client waze

我正在尝试使用 rest-client 库从 Waze 应用程序获取我的 GPS 数据。我基本上是想通过网站 https://www.waze.com/ 伪造登录。登录后(您可以使用 JohnDoeSpeedy228:gre@tStory92),当您访问 https://www.waze.com/editor/ 时,在查看网络调用后单击“驱动器”,您将看到原始 JSON 数据。

我似乎已经成功登录,但是当请求返回我所有驱动器的列表时,它返回以下内容

{"users"=>{"objects"=>[]}, "archives"=>{"totalSessions"=>0, "objects"=>[]}}

它应该返回这样的东西:

{
   "users":{
      "objects":[

      ]
   },
   "archives":{
      "totalSessions":1,
      "objects":[
         {
            "id":<REDACTED>,
            "userID":<REDACTED>,
            "existingRoadMeters":2839,
            "newRoadMeters":0,
            "totalRoadMeters":2839,
            "startTime":1456996197000,
            "endTime":1456996636000,
            "hasFullSession":true
         }
      ]
   }
}

这是我正在尝试的:

require 'rest-client'
require 'json'

GET_CSRF_URL = "https://www.waze.com/login/get"
SESSION_URL = "https://www.waze.com/login/create"
SESSION_LIST_URL = "https://www.waze.com/Descartes-live/app/Archive/List"
SESSON_DATA_URL = "https://www.waze.com/Descartes-live/app/Archive/Session"
AUTH = {'user_id'=>'JohnDoeSpeedy228','password'=>'gre@tStory92'}

req = RestClient.get(GET_CSRF_URL)
csrfhash = req.cookies
csrfhash['editor_env'] = 'row'
headers = {'X-CSRF-Token'=>csrfhash['_csrf_token']}

log = RestClient::Request.execute(
  method: :post,
  url: SESSION_URL,
  cookies: csrfhash,
  headers: headers,
  payload: AUTH
)

ses = RestClient::Request.execute(
  method: :get,
  url: SESSION_LIST_URL,
  cookies: log.cookies,
  payload: {'minDistance'=>1000,'count'=>50, 'offset'=>0}
)

puts JSON.parse(ses)

我做错了什么吗?

最佳答案

我的猜测是您混淆了两个帐户。您确定您以 JohnDoeSpeedy228 身份登录时记录了驱动器吗?如果手动登录网站时没有来自该用户的 session ,我也不希望代码工作。

We can't find any of your drives.

Have you started driving with the Waze app yet? If so, please make sure you logged into the Map Editor with the same credentials you use in the app.

关于ruby - 如何使用 rest-client 从 Waze 获取 GPS 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35768474/

相关文章:

android - 如何从位智中获取两点之间的距离

javascript - 如何修复: “Uncaught SyntaxError: Unexpected token …” on Waze Iframe API using ElectronJS

ios - 在 iOS 上从 PhoneGap 打开位智应用程序的链接

ruby - 如何在 Ruby 中以毫秒为单位计时操作?

java - 如何通过 JRuby 使用 Compass,嵌入到我的软件中?

ruby-on-rails - 在 REST POST 中访问哈希

ruby-on-rails - 无法分配内存

ruby - 如何调试/显示使用 RestClient 发送的请求

java - 从异步 rest 模板 spring 返回值

ruby - 使用splat捕获错误不起作用