1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
| TO = "UXXXXXXXXXXX"
def client
client = Line::Bot::Client.new do |config|
config.channel_secret = "XXXXXXXXXXXXXXXXXXXX"
config.channel_token = "XXXXXXXXXXXXXXXXXXXX"
end
end
def text_msg(text)
{
type: 'text',
text: text
}
end
def jpg_msg(image)
{
type: 'image',
originalContentUrl: image,
previewImageUrl: image
}
end
def map_msg(address,lat,long)
{
type: "location",
title: address,
address: address,
latitude: lat,
longitude: long
}
end
def sticker_msg(pid,sid)
{
type: "sticker",
packageId: pid,
stickerId: sid
}
end
def confirm_msg
{
type: "template",
altText: "this is a confirm template",
template: {
type: "confirm",
text: "要不要去吃火鍋",
actions: [
{
type: "message",
label: "好",
text: "好"
},
{
type: "message",
label: "不好",
text: "不好"
}
]
}
}
end
message = "text"
#送訊息
send = client.push_message( TO, message )
#userId
#event['source']['userId']
#個人資料
response = client.get_profile(TO)
case response
when Net::HTTPSuccess then
contact = JSON.parse(response.body)
p contact['displayName']
p contact['pictureUrl']
p contact['statusMessage']
else
p "#{response.code} #{response.body}"
end
|