LoginSignup
21
22

More than 3 years have passed since last update.

LINE Messaging API が BOT API から変わったところ。

Last updated at Posted at 2016-09-29

サンプルbotはこちら

変更点

良: 友達50人限定だったものが無制限に!
悪: Push API(botから話しかける機能)が月21,600円のプロ版でしか使用できない…

送受信json

メッセージ受信時

BOT API

receiving_message_bot.json
{"result":[
  {
    "from":"u2ddf2eb3c959e561f6c9fa2ea732e7eb8",
    "fromChannel":1341301815,
    "to":["u0cc15697597f61dd8b01cea8b027050e"],
    "toChannel":1441301333,
    "eventType":"138311609000106303",
    "id":"ABCDEF-12345678901",
    "content": {
      "location":null,
      "id":"325708",
      "contentType":1,
      "from":"uff2aec188e58752ee1fb0f9507c6529a",
      "createdTime":1332394961610,
      "to":["u0a556cffd4da0dd89c94fb36e36e1cdc"],
      "toType":1,
      "contentMetadata":null,
      "text":"Hello, BOT API Server!"
    }
  },
  ...
]}

Messaging API

receiving_message_messaging.json
{
  "events": [
      {
        "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
        "type": "message",
        "timestamp": 1462629479859,
        "source": {
             "type": "user",
             "userId": "u206d25c2ea6bd87c17655609a1c37cb8"
         },
         "message": {
             "id": "325708",
             "type": "text",
             "text": "Hello, world"
          }
      }
  ]
}

メッセージ送信時

BOT API

HTTP_Headers.
POST /v1/events HTTP/1.1
Host: trialbot-api.line.me
Content-type: application/json; charset=UTF-8
X-Line-ChannelID: YOUR_CHANNEL_ID
X-Line-ChannelSecret: YOUR_CHANNEL_SECRET
X-Line-Trusted-User-With-ACL: YOUR_CHANNEL_MID
sending_message_bot.json
{
  "to":["u5912407b444e54885d00111f7b0ce375"],
  "toChannel":1383378250,
  "eventType":"138311608800106203",
  "content":{
    "contentType":1,
    "toType":1,
    "text":"Hello, Jose!"
  }
}

Messaging API(プロ版のみ)

HTTP_Headers.
POST
Content-Type:application/json
Authorization: Bearer {ENTER_ACCESS_TOKEN}
sending_message_messaging.json
{
    "to": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "messages":[
        {
            "type":"text",
            "text":"Hello, world1"
        },
        {
            "type":"text",
            "text":"Hello, world2"
        }
    ]

Messaging API(返信)

reply_messaging.json
{
    "replyToken":"nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
    "messages":[
        {
            "type":"text",
            "text":"Hello, user"
        },
        {
            "type":"text",
            "text":"May I help you?"
        }
    ]
}

シンプル!
しかしPush API使いたくて課金してしまう未来の自分が見える…

21
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
22