JSON, CURL and Google's geolocation

2020-03-24 05:11发布

I am trying to use Google's geolocating "browserlocation" service. I have it figured so far that when I try something like

https://maps.googleapis.com/maps/api/browserlocation/json?browser=firefox&sensor=true&
wifi=mac:00-14-bf-28-80-69|ssid:10160|ss:-26&
wifi=mac:00-26-50-38-ca-11|ssid:2WIRE084|ss:-69&
wifi=mac:34-ef-44-7c-0e-b1|ssid:2WIRE202|ss:-70&
wifi=mac:00-1f-b3-64-b3-f1|ssid:2WIRE605|ss:-74&
wifi=mac:00-26-50-e3-1f-81|ssid:2WIRE137|ss:-79&
wifi=mac:00-1d-5a-ef-4d-b9|ssid:2WIRE495|ss:-81&
wifi=mac:c0-83-0a-69-c4-b9|ssid:2WIRE431|ss:-81&
wifi=mac:30-46-9a-43-3d-71|ssid:MacAdamN|ss:-84&
wifi=mac:64-0f-28-bf-e2-91|ssid:2WIRE552|ss:-86&
wifi=mac:00-14-d1-cd-a4-88|ssid:TRENDnet637|ss:-86&
wifi=mac:00-23-5e-b0-70-90|ssid:AppleWiFi|ss:-86&
wifi=mac:00-23-5e-af-39-a0|ssid:AppleWiFi|ss:-86&
wifi=mac:00-1d-d1-55-0d-90|ssid:HOME-0D92|ss:-88

in the browser I get pretty accurate results, check it out for yourself. But when I want to use a JSON file to pass the data with curl like

curl -i -X POST -d @ssids.json "https://maps.googleapis.com/maps/api/browserlocation/json?browser=firefox&sensor=true"

I get horrible accuracy ("accuracy" : 18000.0,). The content of the file ssids.json looks like this:

{
"wifi_access_points": [
    {
        "macAddress": "00-14-bf-28-80-69",
        "signalStrength": "-26"
    },
    {
        "macAddress": "00-26-50-38-ca-11",
        "signalStrength": "-69"
    },
    {
        "macAddress": "00-26-50-38-ca-11",
        "signalStrength": "-69"
    },
    {
        "macAddress": "34-ef-44-7c-0e-b1",
        "signalStrength": "-70"
    },
    {
        "macAddress": "00-1f-b3-64-b3-f1",
        "signalStrength": "-74"
    },
    {
        "macAddress": "00-26-50-e3-1f-81",
        "signalStrength": "-79"
    },
    {
        "macAddress": "00-1d-5a-ef-4d-b9",
        "signalStrength": "-81"
    },
    {
        "macAddress": "c0-83-0a-69-c4-b9",
        "signalStrength": "-81"
    },
    {
        "macAddress": "30-46-9a-43-3d-71",
        "signalStrength": "-84"
    },
    {
        "macAddress": "64-0f-28-bf-e2-91",
        "signalStrength": "-86"
    },
    {
        "macAddress": "00-14-d1-cd-a4-88",
        "signalStrength": "-86"
    },
    {
        "macAddress": "00-23-5e-b0-70-90",
        "signalStrength": "-86"
    },
    {
        "macAddress": "00-23-5e-af-39-a0",
        "signalStrength": "-86"
    },
    {
        "macAddress": "00-1d-d1-55-0d-90",
        "signalStrength": "-88"
    }
]
}

Somehow I know the content of the file is not properly transmitted, but I have NI idea why ...

Would appreciate help, thank you.

1条回答
一夜七次
2楼-- · 2020-03-24 05:39

Your macAddress format needs to be

00:14:bf:28:80:69

instead of this

00-14-bf-28-80-69

also, I think you need to add "age" : xx

查看更多
登录 后发表回答