如何使用php代码向Webhook调用者网址抛出json响应

时间:2018-11-21 14:29:46

标签: php json api dialogflow

如何使用我的php网页中的php代码将以下给出的json响应引发给webhook调用者url(例如https://example.com

{
  "fulfillmentText": "This is a text response",
  "fulfillmentMessages": [
    {
      "card": {
        "title": "card title",
        "subtitle": "card text",
        "imageUri": "https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png",
        "buttons": [
          {
            "text": "button text",
            "postback": "https://assistant.google.com/"
          }
        ]
      }
    }
  ],
  "source": "example.com",
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "this is a simple response"
            }
          }
        ]
      }
    }

1 个答案:

答案 0 :(得分:0)

echo json_encode($data); exit;

documentation