Top / LINE BOT API / 電文フォーマット

試しに何かを入力してみたところ、送られてきた電文は以下の通りでした

{
  "result": [
    {
      "content": {
        "toType": 1,
        "createdTime": 1462347951739,
        "from": "[MID of the user who sent the message.]", 送信者のMID
        "location": null,
        "id": "[Identifier of the message]",
        "to": [
          "[Array of user who will receive the message.]" 受信者のMID配列
        ],
        "text": "てすと",
        "contentMetadata": {
          "AT_RECV_MODE": "2",
          "SKIP_BADGE_COUNT": "true"
        },
        "deliveredTime": 0,
        "contentType": 1,
        "seq": null
      },
      "createdTime": 1462347951776,
      "eventType": "138311609000106303",
      "from": "[Fixed value(ホントかな?) ]",
      "fromChannel": 1341301815,   Fixed valueらしい
      "id": "[ID string to identify each event]",
      "to": [
        "[MID value granted by the BOT API server’s Channel]"
      ],
      "toChannel": [Channel ID of the BOT API server]
    }
  ]
}

送られてくるコンテンツ(文字列、画像、動画、音声、位置情報、スタンプ、連絡先)によって、content部分がいろいろ変化するみたいですね。どのコンテンツが送られてきているかは、そのcontent部分のcontentType (上記は1=文字列) で判定します。

contentType valueDescription
1Text message
2Image message
3Video message
4Audio message
7Location message
8Sticker message
10Contact message

Text message

"content": {
  "toType": 1,
  "createdTime": 1462347951739,
  "from": "[MID of the user who sent the message.]", 
  "location": null,
  "id": "[Identifier of the message]",
  "to": [
    "[Array of user who will receive the message.]"
  ],
  "text": "てすと",
  "contentMetadata": {
    "AT_RECV_MODE": "2",
    "SKIP_BADGE_COUNT": "true"
  },
  "deliveredTime": 0,
  "contentType": 1,
  "seq": null
}

Image message

"content": {
  "toType": 1,
  "createdTime": 1462347958123,
  "from": "[MID of the user who sent the message.]",
  "location": null,
  "id": "[Identifier of the message]",
  "to": [
    "[Array of user who will receive the message.]"
  ],
  "text": "",
  "contentMetadata": {
    "AT_RECV_MODE": "2",
    "SKIP_BADGE_COUNT": "true"
  },
  "deliveredTime": 0,
  "contentType": 2,
  "seq": null
}

Video message

"content": {
  "toType": 1,
  "createdTime": 1462348013683,
  "from": "[MID of the user who sent the message.]",
  "location": null,
  "id": "[Identifier of the message]",
  "to": [
    "[Array of user who will receive the message.]"
  ],
  "text": "",
  "contentMetadata": {
    "AT_RECV_MODE": "2",
    "SKIP_BADGE_COUNT": "true"
  },
  "deliveredTime": 0,
  "contentType": 3,
  "seq": null
}

Audio message

"content": {
  "toType": 1,
  "createdTime": 1462348038226,
  "from": "[MID of the user who sent the message.]",
  "location": null,
  "id": "[Identifier of the message]",
  "to": [
    "[Array of user who will receive the message.]"
  ],
  "text": "",
  "contentMetadata": {
    "OBS_POP": "b",
    "AT_RECV_MODE": "2",
    "AUDLEN": "3064",
    "SKIP_BADGE_COUNT": "true"
  },
  "deliveredTime": 0,
  "contentType": 4,
  "seq": null
}

Location message

"content": {
  "toType": 1,
  "createdTime": 1462347972512,
  "from": "[MID of the user who sent the message.]",
  "location": {
    "title": "位置情報",
    "address": " 〒xxx-xxxx 東京都xxxxxxxxxxxxxxxxx",
    "latitude": [緯度],
    "longitude": [経度],
    "phone": null
  },
  "id": "[Identifier of the message]",
  "to": [
    "[Array of user who will receive the message.]"
  ],
  "text": null,
  "contentMetadata": {
    "AT_RECV_MODE": "2",
    "SKIP_BADGE_COUNT": "true"
  },
  "deliveredTime": 0,
  "contentType": 7,
  "seq": null
}

Sticker message

"content": {
  "toType": 1,
  "createdTime": 1462347993325,
  "from": "[MID of the user who sent the message.]",
  "location": null,
  "id": "[Identifier of the message]",
  "to": [
    "[Array of user who will receive the message.]"
  ],
  "text": null,
  "contentMetadata": {
    "STKTXT": "[スタンプ]",
    "AT_RECV_MODE": "2",
    "STKVER": "100",
    "STKID": "114",
    "STKPKGID": "1",
    "SKIP_BADGE_COUNT": "true"
  },
  "deliveredTime": 0,
  "contentType": 8,
  "seq": null
}

Contact message

"content": {
  "toType": 1,
  "createdTime": 1462348079866,
  "from": "[MID of the user who sent the message.]",
  "location": null,
  "id": "[Identifier of the message]",
  "to": [
    "[Array of user who will receive the message.]"
  ],
  "text": null,
  "contentMetadata": {
    "mid": "[連絡先のMID]",
    "AT_RECV_MODE": "2",
    "displayName": "[連絡先の名前]",
    "SKIP_BADGE_COUNT": "true"
  },
  "deliveredTime": 0,
  "contentType": 10,
  "seq": null
}

関連リンク


この記事は

選択肢 投票
おもしろかった 0  
そうでもない 0  

Top / LINE BOT API / 電文フォーマット

現在のアクセス:876


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-05-05 (木) 20:47:41 (1288d)