【问题标题】:Geolocation API handling on iOS ShortcutsiOS 快捷方式上的地理定位 API 处理
【发布时间】:2019-04-18 06:28:20
【问题描述】:

我正在开发一个使用基于 MAC 地址的 Google 地理定位 API 的简单项目。

我已经编写了 20 多个类似的基于 Web 的 JSON 项目,但是,我无法让它在 iOS 上的 Shortcuts 上运行。它在 curl 上运行良好,因为 Geolocation API - Developer Guide 中描述的 Google curl 示例代码但是,在 IOS 快捷方式中重写代码会返回“未找到”错误。有人有在 Shortcuts 上使用 WiFi Mac 地址地理定位 API 的经验吗?

用于地理定位的 curl 脚本非常简单。

curl -d @test.json -H "Content-Type: application/json" -i "https://www.googleapis.com/geolocation/v1/geolocate?key=[MY_API_KEY]

test.json 包含来自google 示例页面的示例数据,内容如下。

---- test.json 从这里开始-----

{
    "considerIp": "false",
    "wifiAccessPoints": [
    {
        "macAddress": "00:25:9c:cf:1c:ac",
        "signalStrength": -43,
        "signalToNoiseRatio": 0
    },
    {
        "macAddress": "00:25:9c:cf:1c:ad",
        "signalStrength": -55,
        "signalToNoiseRatio": 0
    }
  ]
}

---- test.json 到此结束-----

这是我在快捷方式中的代码。

【问题讨论】:

    标签: ios geolocation shortcut


    【解决方案1】:

    enter image description here嗯,经过几个小时的尝试,我找到了一种获取坐标的方法。我知道这不是一个聪明的方法,但是在请求正文中使用“文件”就像 curl 返回正确的坐标一样。正确答案是 (33.3632..., -117.0872...)

    enter image description here

    【讨论】:

      猜你喜欢
      • 2020-10-04
      • 1970-01-01
      • 1970-01-01
      • 2019-10-02
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 2013-11-08
      • 2016-11-14
      相关资源
      最近更新 更多