EventRequestParserTest
extends TestCase
Table of Contents
-
$json
: mixed
-
testParseEventRequest()
: mixed
-
getSignature()
: string
$json
private
static mixed
$json
= <<<JSON
{
"destination":"U0123456789abcdef0123456789abcd",
"events":[
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"text",
"text":"message (love)",
"emojis": [
{
"index": 8,
"length": 6,
"productId": "5ac1bfd5040ab15980c9b435",
"emojiId": "001"
}
]
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"group",
"groupId":"groupid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"image",
"contentProvider":{
"type":"external",
"originalContentUrl":"https://example.com/test.jpg",
"previewImageUrl":"https://example.com/test-preview.jpg"
},
"imageSet": {
"id": "E005D41A7288F41B65593ED38FF6E9834B046AB36A37921A56BC236F13A91855",
"index": 1,
"total": 1
}
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"group",
"groupId":"groupid",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"audio",
"duration":10000,
"contentProvider":{
"type":"external",
"originalContentUrl":"https://example.com/test.m4a"
}
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"room",
"roomId":"roomid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"video",
"duration":10000,
"contentProvider":{
"type":"external",
"originalContentUrl":"https://example.com/test.mp4",
"previewImageUrl":"https://example.com/test-preview.jpg"
}
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"room",
"roomId":"roomid",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"audio",
"duration":10000,
"contentProvider":{
"type":"external",
"originalContentUrl":"https://example.com/test.m4a"
}
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"location",
"title":"label",
"address":"tokyo",
"latitude":-34.12,
"longitude":134.23
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"location",
"address":"tokyo",
"latitude":-34.12,
"longitude":134.23
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"location",
"title":"label",
"latitude":-34.12,
"longitude":134.23
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"sticker",
"packageId":"1",
"stickerId":"2",
"stickerResourceType":"STATIC"
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"sticker",
"packageId":"12287",
"stickerId":"738839",
"stickerResourceType":"MESSAGE",
"keywords": ["Anticipation","Sparkle","Straight face","Staring","Thinking"],
"text": "Let's\\nhang out\\nthis weekend!"
}
},
{
"type":"follow",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken"
},
{
"type":"unfollow",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
}
},
{
"type":"join",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken"
},
{
"type":"leave",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
}
},
{
"type":"postback",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"postback":{
"data":"postback"
}
},
{
"type":"beacon",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"beacon":{
"hwid":"bid",
"type":"enter",
"dm":"1234567890abcdef"
}
},
{
"type":"__unknown__",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
}
},
{
"type":"__unknown__",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"__unknown__"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"__unknown__"
}
},
{
"replyToken": "replytoken",
"type": "message",
"mode":"active",
"timestamp": 1462629479859,
"source": {
"type": "user",
"userId": "userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"message": {
"id": "325708",
"type": "file",
"fileName": "file.txt",
"fileSize": 2138
}
},
{
"replyToken": "replytoken",
"type": "postback",
"mode":"active",
"timestamp": 1501234567890,
"source": {
"type": "user",
"userId": "userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"postback": {
"data":"postback",
"params": {
"date": "2013-04-01"
}
}
},
{
"replyToken": "replytoken",
"type": "postback",
"mode":"active",
"timestamp": 1501234567890,
"source": {
"type": "user",
"userId": "userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"postback": {
"data":"postback",
"params": {
"time": "10:00"
}
}
},
{
"replyToken": "replytoken",
"type": "postback",
"mode":"active",
"timestamp": 1501234567890,
"source": {
"type": "user",
"userId": "userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"postback": {
"data":"postback",
"params": {
"datetime": "2013-04-01T10:00"
}
}
},
{
"replyToken": "replytoken",
"type": "accountLink",
"mode":"standby",
"timestamp": 1501234567890,
"source": {
"type": "user",
"userId": "userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"link": {
"result": "ok",
"nonce": "1234567890abcdefghijklmnopqrstuvwxyz"
}
},
{
"replyToken": "replytoken",
"type": "accountLink",
"mode":"active",
"timestamp": 1501234567890,
"source": {
"type": "user",
"userId": "userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"link": {
"result": "failed",
"nonce": "1234567890abcdefghijklmnopqrstuvwxyz"
}
},
{
"type":"memberJoined",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"group",
"groupId":"groupid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"joined": {
"members": [
{
"type": "user",
"userId": "U4af4980629..."
},
{
"type": "user",
"userId": "U91eeaf62d9..."
}
]
},
"replyToken":"replytoken"
},
{
"type":"memberLeft",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"group",
"groupId":"groupid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"left": {
"members": [
{
"type": "user",
"userId": "U4af4980629..."
},
{
"type": "user",
"userId": "U91eeaf62d9..."
}
]
}
},
{
"type":"things",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"things":{
"deviceId":"t2c449c9d1",
"type": "link"
}
},
{
"type":"things",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"things":{
"deviceId":"t2c449c9d1",
"type": "unlink"
}
},
{
"type": "things",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"things": {
"type": "scenarioResult",
"deviceId": "t2c449c9d1",
"result": {
"scenarioId": "dummy_scenario_id",
"revision": 2,
"startTime": 1547817845950,
"endTime": 1547817845952,
"resultCode": "success",
"bleNotificationPayload": "AQ==",
"actionResults": [
{
"type": "binary",
"data": "/w=="
}
]
}
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"text",
"text":"message without emoji"
}
},
{
"type":"unsend",
"timestamp":12345678901234,
"source":{
"type": "group",
"groupId":"groupid",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"unsend": {
"messageId": "325708"
}
},
{
"type":"videoPlayComplete",
"timestamp":12345678901234,
"source":{
"type": "group",
"groupId":"groupid",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"videoPlayComplete": {
"trackingId": "track_id"
},
"replyToken":"replytoken"
},
{
"replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
"type": "message",
"mode": "active",
"timestamp": 1462629479859,
"source": {
"type": "user",
"userId": "U4af4980629..."
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"message": {
"id": "325708",
"type": "text",
"text": "@example Hello, world! (love)",
"mention": {
"mentionees": [
{
"type": "user",
"index": 0,
"length": 8,
"userId": "U0123456789abcd0123456789abcdef"
}
]
}
}
},
{
"replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
"type": "message",
"mode": "active",
"timestamp": 1462629479859,
"source": {
"type": "user",
"userId": "U0123456789abcd0123456789abcdef"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"message": {
"id": "325708",
"type": "text",
"text": "@example message without mentionee userId",
"mention": {
"mentionees": [
{
"type": "all",
"index": 0,
"length": 8
}
]
}
}
},
{
"replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
"type": "message",
"mode": "active",
"timestamp": 1462629479859,
"source": {
"type": "user",
"userId": "U0123456789abcd0123456789abcdef"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"message": {
"id": "325708",
"type": "text",
"text": "message without mention"
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"group",
"groupId":"groupid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"image",
"contentProvider":{
"type":"external",
"originalContentUrl":"https://example.com/test.jpg",
"previewImageUrl":"https://example.com/test-preview.jpg"
}
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"group",
"groupId":"groupid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":false
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"image",
"contentProvider":{
"type":"external",
"originalContentUrl":"https://example.com/test.jpg",
"previewImageUrl":"https://example.com/test-preview.jpg"
},
"imageSet": {
"id": "E005D41A7288F41B65593ED38FF6E9834B046AB36A37921A56BC236F13A91855"
}
}
},
{
"type":"message",
"mode":"active",
"timestamp":12345678901234,
"source":{
"type":"user",
"userId":"userid"
},
"webhookEventId":"testwebhookeventid",
"deliveryContext":{
"isRedelivery":true
},
"replyToken":"replytoken",
"message":{
"id":"contentid",
"type":"text",
"text":"message (love)",
"emojis": [
{
"index": 8,
"length": 6,
"productId": "5ac1bfd5040ab15980c9b435",
"emojiId": "001"
}
]
}
},
{
"type": "activated",
"timestamp": 12345678901234,
"mode": "active",
"source": {
"type": "user",
"userId": "userid"
},
"chatControl": {
"expireAt": 1462629479860
},
"webhookEventId": "testwebhookeventid",
"deliveryContext": {
"isRedelivery": false
}
},
{
"type": "deactivated",
"timestamp": 12345678901234,
"mode": "active",
"source": {
"type": "user",
"userId": "userid"
},
"webhookEventId": "testwebhookeventid",
"deliveryContext": {
"isRedelivery": false
}
},
{
"type": "botSuspended",
"timestamp": 12345678901234,
"mode": "active",
"webhookEventId": "testwebhookeventid",
"deliveryContext": {
"isRedelivery": false
}
},
{
"type": "botResumed",
"timestamp": 12345678901234,
"mode": "active",
"webhookEventId": "testwebhookeventid",
"deliveryContext": {
"isRedelivery": false
}
},
{
"type": "delivery",
"timestamp": 12345678901234,
"mode": "active",
"source": {
"type": "user",
"userId": "userid"
},
"delivery": {
"data": "deliverydata"
},
"webhookEventId": "testwebhookeventid",
"deliveryContext": {
"isRedelivery": false
}
},
{
"type": "module",
"timestamp": 12345678901234,
"mode": "active",
"module": {
"type": "attached",
"botId": "botid",
"scopes": ["a", "b"]
},
"webhookEventId": "testwebhookeventid",
"deliveryContext": {
"isRedelivery": false
}
},
{
"type": "module",
"timestamp": 12345678901234,
"mode": "active",
"module": {
"type": "detached",
"botId": "botid",
"reason": "bot deleted"
},
"webhookEventId": "testwebhookeventid",
"deliveryContext": {
"isRedelivery": false
}
}
]
}
JSON