-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirstbot_push.php
78 lines (77 loc) · 2.54 KB
/
firstbot_push.php
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
<?php
function flex_msg()
{
//
$json1 = '{
"type":"flex",
"altText":"Green Office",
"contents":{
"type": "bubble",
"header": {
"type": "box",
"layout": "horizontal",
"contents": [
{
"type": "text",
"text": "ประชาสัมพันธ์ ประชาสัมพันธ์",
"weight": "bold",
"color": "#B7F4A9",
"align": "center",
"size": "md"
}
]
},
"hero": {
"type": "image",
"url": "https://meetingnotify.herokuapp.com/pic/the-assist.png",
"size": "full",
"aspectRatio": "20:13",
"aspectMode": "cover"
},
"footer": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "spacer",
"size": "xs"
},
{
"type": "button",
"style": "primary",
"color": "#B7F4A9",
"action": {
"type": "uri",
"label": "รายละเอียด",
"uri": "https://linecorp.com"
}
}
]
}
}
}';
$result = json_decode($json1);
return $result;
}
function push()
{
$access_token = 'HScoQtJ9WeTsUePpz0xZ7vo//Tm7j+PR/LCoi09r4L7XDPJVZr/Bc3iSn6NGBJVa8LpQM446o/uIUbLxOfjm09FDX+73peOuXqHvKttcHLeqogyWj0RU/Vqj1LapFoxfp2lOPYq4O8ErqPnZGyRpPAdB04t89/1O/w1cDnyilFU=';
$id = 'Ua9ba6c25071c19588c095ec147efe2b1';
//$messages = [ 'type' => 'text','text' => "jdakljkskljd"];
$messages = flex_msg();
$url = 'https://api.line.me/v2/bot/message/push';
$data = ['to' => $id,'messages' => [$messages]];
$post = json_encode($data);
$headers = array('Content-Type: application/json', 'Authorization: Bearer ' . $access_token);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
}
push();
echo "OK.....นะคะ";
?>