質問編集履歴
1
変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
LINE Message API でおうむ返しされない
|
test
CHANGED
@@ -4,184 +4,156 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
最後まで、
|
7
|
+
最後まで、実行しこのようなメッセージを取得しました。
|
8
8
|
|
9
|
-
詳細は以下です。
|
10
|
-
|
11
|
-
```
|
9
|
+
```ターミナル
|
12
|
-
|
13
|
-
mbp:baseballbot1011 yutanakai$ git init
|
14
|
-
|
15
|
-
Initialized empty Git repository in /Applications/MAMP/htdocs/baseballbot1011/.git/
|
16
|
-
|
17
|
-
mbp:baseballbot1011 yutanakai$ ls
|
18
|
-
|
19
|
-
LINEBotTiny.php index.php webhook.php
|
20
|
-
|
21
|
-
mbp:baseballbot1011 yutanakai$
|
22
|
-
|
23
|
-
mbp:baseballbot1011 yutanakai$
|
24
|
-
|
25
|
-
mbp:baseballbot1011 yutanakai$ heroku git:remote -a baseballbot1011
|
26
|
-
|
27
|
-
set git remote heroku to https://git.heroku.com/baseballbot1011.git
|
28
|
-
|
29
|
-
mbp:baseballbot1011 yutanakai$ git add .
|
30
|
-
|
31
|
-
mbp:baseballbot1011 yutanakai$ git commit -am "make it better"
|
32
|
-
|
33
|
-
[master (root-commit) 7553c4c] make it better
|
34
|
-
|
35
|
-
Committer: xxxxx <yutanakai@mbp.local>
|
36
|
-
|
37
|
-
Your name and email address were configured automatically based
|
38
|
-
|
39
|
-
on your username and hostname. Please check that they are accurate.
|
40
|
-
|
41
|
-
You can suppress this message by setting them explicitly. Run the
|
42
|
-
|
43
|
-
following command and follow the instructions in your editor to edit
|
44
|
-
|
45
|
-
your configuration file:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
git config --global --edit
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
After doing this, you may fix the identity used for this commit with:
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
git commit --amend --reset-author
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
3 files changed, 174 insertions(+)
|
62
|
-
|
63
|
-
create mode 100644 LINEBotTiny.php
|
64
|
-
|
65
|
-
create mode 100644 index.php
|
66
|
-
|
67
|
-
create mode 100644 webhook.php
|
68
|
-
|
69
|
-
mbp:baseballbot1011 yutanakai$ push heroku master
|
70
|
-
|
71
|
-
-bash: push: command not found
|
72
|
-
|
73
|
-
mbp:baseballbot1011 yutanakai$
|
74
10
|
|
75
11
|
mbp:baseballbot1011 yutanakai$ git push heroku master
|
76
12
|
|
77
|
-
E
|
13
|
+
Everything up-to-date
|
78
|
-
|
79
|
-
Counting objects: 100% (5/5), done.
|
80
|
-
|
81
|
-
Delta compression using up to 12 threads
|
82
|
-
|
83
|
-
Compressing objects: 100% (4/4), done.
|
84
|
-
|
85
|
-
Writing objects: 100% (5/5), 2.64 KiB | 2.64 MiB/s, done.
|
86
|
-
|
87
|
-
Total 5 (delta 0), reused 0 (delta 0)
|
88
|
-
|
89
|
-
remote: Compressing source files... done.
|
90
|
-
|
91
|
-
remote: Building source:
|
92
|
-
|
93
|
-
remote:
|
94
|
-
|
95
|
-
remote: -----> PHP app detected
|
96
|
-
|
97
|
-
remote:
|
98
|
-
|
99
|
-
remote: ! WARNING: No 'composer.json' found!
|
100
|
-
|
101
|
-
remote: !
|
102
|
-
|
103
|
-
remote: ! Your project only contains an 'index.php', no 'composer.json'.
|
104
|
-
|
105
|
-
remote: !
|
106
|
-
|
107
|
-
remote: ! Using 'index.php' to declare app type as PHP is deprecated and
|
108
|
-
|
109
|
-
remote: ! may lead to unexpected behavior.
|
110
|
-
|
111
|
-
remote: !
|
112
|
-
|
113
|
-
remote: ! Please consider updating your codebase to utilize Composer and
|
114
|
-
|
115
|
-
remote: ! modern dependency management in order to benefit from the latest
|
116
|
-
|
117
|
-
remote: ! PHP runtimes and improved application performance, as well as
|
118
|
-
|
119
|
-
remote: ! control over the PHP versions and extensions available.
|
120
|
-
|
121
|
-
remote: !
|
122
|
-
|
123
|
-
remote: ! For an introduction to dependency management with Composer and
|
124
|
-
|
125
|
-
remote: ! how to get the most out of PHP on Heroku, refer to the docs at
|
126
|
-
|
127
|
-
remote: ! https://getcomposer.org/doc/00-intro.md and
|
128
|
-
|
129
|
-
remote: ! https://devcenter.heroku.com/articles/getting-started-with-php
|
130
|
-
|
131
|
-
remote:
|
132
|
-
|
133
|
-
remote: -----> Bootstrapping...
|
134
|
-
|
135
|
-
remote: -----> Installing platform packages...
|
136
|
-
|
137
|
-
remote: NOTICE: No runtime required in composer.lock; using PHP ^7.0.0
|
138
|
-
|
139
|
-
remote: - php (7.3.10)
|
140
|
-
|
141
|
-
remote: - apache (2.4.41)
|
142
|
-
|
143
|
-
remote: - nginx (1.16.1)
|
144
|
-
|
145
|
-
remote: -----> Installing dependencies...
|
146
|
-
|
147
|
-
remote: Composer version 1.9.0 2019-08-02 20:55:32
|
148
|
-
|
149
|
-
remote: -----> Preparing runtime environment...
|
150
|
-
|
151
|
-
remote: NOTICE: No Procfile, using 'web: heroku-php-apache2'.
|
152
|
-
|
153
|
-
remote: -----> Checking for additional extensions to install...
|
154
|
-
|
155
|
-
remote: -----> Discovering process types
|
156
|
-
|
157
|
-
remote: Procfile declares types -> web
|
158
|
-
|
159
|
-
remote:
|
160
|
-
|
161
|
-
remote: -----> Compressing...
|
162
|
-
|
163
|
-
remote: Done: 15.7M
|
164
|
-
|
165
|
-
remote: -----> Launching...
|
166
|
-
|
167
|
-
remote: Released v3
|
168
|
-
|
169
|
-
remote: https://baseballbot1011.herokuapp.com/ deployed to Heroku
|
170
|
-
|
171
|
-
remote:
|
172
|
-
|
173
|
-
remote: Verifying deploy... done.
|
174
|
-
|
175
|
-
To https://git.heroku.com/baseballbot1011.git
|
176
14
|
|
177
15
|
```
|
178
16
|
|
179
17
|
|
180
18
|
|
181
|
-
|
19
|
+
おそらくデプロイは成功したはずです。
|
182
|
-
|
183
|
-
問題はなんなのでしょうか?
|
184
20
|
|
185
21
|
|
186
22
|
|
23
|
+
この状態で、手順に間違いがなけば、LINEにメッセージを送信すればおうむ返しされるはずですが、何も返信がありません。
|
24
|
+
|
25
|
+
webhook.phpのコードは以下です。
|
26
|
+
|
27
|
+
```php
|
28
|
+
|
29
|
+
<?php
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
/**
|
34
|
+
|
35
|
+
* Copyright 2016 LINE Corporation
|
36
|
+
|
37
|
+
*
|
38
|
+
|
39
|
+
* LINE Corporation licenses this file to you under the Apache License,
|
40
|
+
|
41
|
+
* version 2.0 (the "License"); you may not use this file except in compliance
|
42
|
+
|
43
|
+
* with the License. You may obtain a copy of the License at:
|
44
|
+
|
45
|
+
*
|
46
|
+
|
47
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
48
|
+
|
49
|
+
*
|
50
|
+
|
51
|
+
* Unless required by applicable law or agreed to in writing, software
|
52
|
+
|
53
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
54
|
+
|
55
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
56
|
+
|
57
|
+
* License for the specific language governing permissions and limitations
|
58
|
+
|
59
|
+
* under the License.
|
60
|
+
|
61
|
+
*/
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
require_once('./LINEBotTiny.php');
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
$channelAccessToken = '3ENAVejEiHo8nGiSQkxhbV4mt858J6PBl0u2ScmnDeJaWSTqwyWOOPbq70YTjxsn+N6LEJVpGXTZIv3vmimKFL1OpslcthNuI/MtirK9+5ruTSXhBS5owjxTIbBjg6K+tkFQSoLgj9oULZaEFAxN/QdB04t89/1O/w1cDnyilFU=';
|
70
|
+
|
71
|
+
$channelSecret = 'abb0af32806f6d58706f30a71edd3be3';
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
$client = new LINEBotTiny($channelAccessToken, $channelSecret);
|
76
|
+
|
77
|
+
foreach ($client->parseEvents() as $event) {
|
78
|
+
|
79
|
+
switch ($event['type']) {
|
80
|
+
|
81
|
+
case 'message':
|
82
|
+
|
83
|
+
$message = $event['message'];
|
84
|
+
|
85
|
+
switch ($message['type']) {
|
86
|
+
|
87
|
+
case 'text':
|
88
|
+
|
89
|
+
$client->replyMessage([
|
90
|
+
|
91
|
+
'replyToken' => $event['replyToken'],
|
92
|
+
|
93
|
+
'messages' => [
|
94
|
+
|
95
|
+
[
|
96
|
+
|
97
|
+
'type' => 'text',
|
98
|
+
|
99
|
+
'text' => $message['text']
|
100
|
+
|
101
|
+
]
|
102
|
+
|
103
|
+
]
|
104
|
+
|
105
|
+
]);
|
106
|
+
|
107
|
+
break;
|
108
|
+
|
109
|
+
default:
|
110
|
+
|
111
|
+
error_log('Unsupported message type: ' . $message['type']);
|
112
|
+
|
113
|
+
break;
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
break;
|
118
|
+
|
119
|
+
default:
|
120
|
+
|
121
|
+
error_log('Unsupported event type: ' . $event['type']);
|
122
|
+
|
123
|
+
break;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
};
|
128
|
+
|
129
|
+
```
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
何か間違いがあるとすれば、なんでしょうか。言っていただければ編集します。
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
--------LINEの設定-------------
|
140
|
+
|
141
|
+
|
142
|
+
|
187
|
-
|
143
|
+
**Channel access token (long-lived) **
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
3ENAVejEiHo8nGiSQkxhbV4mt858J6PBl0u2ScmnDeJaWSTqwyWOOPbq70YTjxsn+N6LEJVpGXTZIv3vmimKFL1OpslcthNuI/MtirK9+5ruTSXhBS5owjxTIbBjg6K+tkFQSoLgj9oULZaEFAxN/QdB04t89/1O/w1cDnyilFU=
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
**Channel secre**
|
152
|
+
|
153
|
+
abb0af32806f6d58706f30a71edd3be3
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
**Webhook URL Requires SSL**
|
158
|
+
|
159
|
+
https://baseballbot1011.herokuapp.com/webhook.php
|