【问题标题】:Orion notification complex payloadOrion 通知复杂负载
【发布时间】:2017-05-18 15:22:19
【问题描述】:

我正在尝试使用 Orion 通知通过 Plivo 发送短信。 这就是我直接使用 Plivo 发送 SMS 的方式:

curl -X POST https://api.plivo.com/v1/Account/MAMDA5ZDJIMDM1/Message/ -L -u MAMDA5ZDJIM:YzhiNDJjODNhNDkxMjhiYTgxZD -H 'Content-Type: application/json' -d @- <<EOF
{
   "src": "0039414141414",
   "dst": "0039414747111",
   "text": "test SMS"
}
EOF

我应该如何在 Orion 中对其进行编码?我试过了:

curl localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' --header 'Accept: application/json'  -d @- <<EOF
{
  "description": "A subscription to get info about WS_UPPA_Sensor2",
  "subject": {
    "entities": [
      {
        "id": "Sensor1",
        "type": "SensingDevice"
      }
    ],
    "condition": {
      "attrs": [
        "temperature"
      ]
    }
  },
  "notification": {
    "httpCustom": {
      "url": "https://api.plivo.com/v1/Account/MAMDA5ZDJIMDM1NZVMZD/Message/",
      "headers": {
         "Authorization": "Basic TUFNREE1WkRKSU1ETTFOWlZNWkQ6WXpoaU5ESmpPRE5oTkRreE1qaGlZVGd4WkRkaE5qYzNPV1ZsTnpZMA=="
      },
      "payload": "{%22src%22%3A%2200393806412092%22%2C%22dst%22%3A%2200393806412093%22%2C%22text%22%3A%22test%20SMS%20from%20Waziup%22}"

    },
    "attrs": [
      "temperature"
    ]
  },
  "expires": "2040-01-01T14:00:00.00Z",
  "throttling": 5
}
EOF

除了百分比编码还有其他方法吗?

【问题讨论】:

    标签: fiware-orion plivo


    【解决方案1】:

    URL encoding(我理解是你所说的“百分比编码”)是唯一一个在自定义通知中有特殊处理(详情描述为part of the Orion documentation)。

    其实考虑到现有的是完整的(我的意思是,任何文字都可以用URL编码的方式来表达)就不需要再添加任何其他的了。

    【讨论】:

    • fiware-orion.readthedocs.io/en/master/user/forbidden_characters/… 中所见,我这样编码我的有效负载: "payload": "{ %22src%22: %2200393806412092%22, %22dst%22: %2200393806412093%22, %22text% 22: %22test%22}" 正确吗?只有引号需要转义(不是“}”或“:”或“,”)?
    • 没错。 "}"、":" 和 "," 不是禁止字符,因此可以直接使用。我建议检查 Orion 实际发送的内容,例如使用requestb.in 工具(当然,相应地调整订阅"url")。
    猜你喜欢
    • 1970-01-01
    • 2015-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多