質問編集履歴

7

説明の訂正

2018/07/31 14:57

投稿

GeorgeYamagata
GeorgeYamagata

スコア8

test CHANGED
File without changes
test CHANGED
@@ -122,6 +122,8 @@
122
122
 
123
123
  実行したところ


124
124
 
125
+
126
+
125
127
  ・/home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitter_bot.php: 行 1: ?php: そのようなファイルやディレクトリはありません
126
128
 
127
129
 

6

説明の訂正

2018/07/31 14:56

投稿

GeorgeYamagata
GeorgeYamagata

スコア8

test CHANGED
File without changes
test CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
 
8
8
 
9
- 

コードは下記のサイトを参考に致しました。
【2016年最新②】
9
+ 

コードは下記のサイトを参考に致しました。
【2016年最新②】
10
10
 
11
- 
【2016年最新②】TwitterBot用のPHP作成とCron設定方法
https://harublog.popnavi.net/programming/twitterbot_php_cron/

11
+ 
【2016年最新②】TwitterBot用のPHP作成とCron設定方法
https://harublog.popnavi.net/programming/twitterbot_php_cron/

12
12
 
13
13
 
14
14
 

5

説明の訂正

2018/07/31 14:56

投稿

GeorgeYamagata
GeorgeYamagata

スコア8

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- 現在twitter botで、現在の時刻を呟くbotを作ろうとしています。
1
+ 番号リスト現在twitter botで、現在の時刻を呟くbotを作ろうとしています。
2
2
 
3
3
  
そこで、vagrant仮想環境のcentOSでは、実行することができました。

4
4
 
@@ -100,19 +100,17 @@
100
100
 
101
101
  そこで、次にxserverのドメイン名の下のpublic_htmlにcentOSで実行できたtwitter-bot-original1をそのまま移動させて、
102
102
 
103
- twitter-bot-original1(ディレクトリ) ここにいる状態から実行するようにしている
103
+ twitter-bot-original1(ディレクトリ) ここから実行するようにしている
104
104
 
105
- 
/home/サーバーID/ドメイン名/public_html/twitter- twitter_bot.php
105
+ 
/home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitter_bot.php
106
106
 
107
- - config.php
107
+ /home/サーバーID/ドメイン名/public_html/twitter-bot-original1/config.php
108
108
 
109
- - twitteroauth(ディレクトリ)
109
+ /home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitteroauth/autoload.php
110
110
 
111
- - autoload.php
111
+ /home/サーバーID/ドメイン名/public_html/twitter-bot-original1/src/TwitterOAuth.php
112
112
 
113
- - src(ディレクトリ)
114
-
115
- - TwitterOAuth.php
113
+ TwitterOAuth.php
116
114
 
117
115
 
118
116
 

4

誤字の訂正

2018/07/31 14:55

投稿

GeorgeYamagata
GeorgeYamagata

スコア8

test CHANGED
File without changes
test CHANGED
@@ -13,20 +13,6 @@
13
13
 
14
14
 
15
15
  twitterbotを動かす、PHPファイルはhttps://github.com/abraham/twitteroauth ここからダウンロードして使っております

16
-
17
-
18
-
19
- twitter-bot-original1これはbotを動かす為のフォルダです
20
-
21
- vagrantでの階層
22
-
23
- /home/vagrant/twitter-bot-original1
24
-
25
- twitter-bot-original1-config.php -twitter_bot.php
26
-
27
- -config.php
28
-
29
- -twitteroauth(これはディレクトリ)
30
16
 
31
17
 
32
18
 
@@ -112,7 +98,25 @@
112
98
 
113
99
 
114
100
 
115
- そこで、次にxserverのドメイン名の下のpublic_htmlにcentOSで実行できたtwitter-bot-original1をそのまま移動させて、
cron設定のコマンドに
101
+ そこで、次にxserverのドメイン名の下のpublic_htmlにcentOSで実行できたtwitter-bot-original1をそのまま移動させて、
cron設定のコマンドに
102
+
103
+ twitter-bot-original1(ディレクトリ) ここにいる状態から実行するようにしている
104
+
105
+ - twitter_bot.php
106
+
107
+ - config.php
108
+
109
+ - twitteroauth(ディレクトリ)
110
+
111
+ - autoload.php
112
+
113
+ - src(ディレクトリ)
114
+
115
+ - TwitterOAuth.php
116
+
117
+
118
+
119
+ 
cron設定のコマンドに
116
120
 
117
121
  
/home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitter_bot.php
118
122
 

3

誤字の訂正

2018/07/31 14:52

投稿

GeorgeYamagata
GeorgeYamagata

スコア8

test CHANGED
File without changes
test CHANGED
@@ -38,7 +38,7 @@
38
38
 
39
39
  **************************************************************
40
40
 
41
- <?php
41
+ 行1<?php
42
42
 
43
43
  行2 require_once('twitteroauth/autoload.php');
44
44
 

2

誤字の訂正

2018/07/31 14:15

投稿

GeorgeYamagata
GeorgeYamagata

スコア8

test CHANGED
File without changes
test CHANGED
@@ -12,11 +12,11 @@
12
12
 
13
13
 
14
14
 
15
- twitterbotを動かす、PHPファイルはhttps://github.com/abraham/twitteroauth ここからダウンロードして使っております
こちらが書いたtwitter_bot.phpコードです。

15
+ twitterbotを動かす、PHPファイルはhttps://github.com/abraham/twitteroauth ここからダウンロードして使っております
こちらが書いたtwitter_bot.phpコードです。

16
16
 
17
17
 
18
18
 
19
- twitter-bot-original1これbotを動かす為のフォルダです
19
+ twitter-bot-original1これbotを動かす為のフォルダです
20
20
 
21
21
  vagrantでの階層
22
22
 
@@ -29,6 +29,8 @@
29
29
  -twitteroauth(これはディレクトリ)
30
30
 
31
31
 
32
+
33
+ こちらが書いたtwitter_bot.phpコードです。

32
34
 
33
35
  twitter_bot.php
34
36
 

1

実行環境とコードの追加、見やすさの改善

2018/07/31 14:14

投稿

GeorgeYamagata
GeorgeYamagata

スコア8

test CHANGED
File without changes
test CHANGED
@@ -1,49 +1,177 @@
1
- twitter bot をphp7.0.30のバージョンで、時刻を呟くbotを作ていて、
1
+ 現在twitter botで、現在の時刻を呟くbotを作ろうとしています。
2
2
 
3
- 
そこで、vagrant仮想環境では、実行できたので、。

3
+ 
そこで、vagrant仮想環境のcentOSでは、実行することができまし。

4
+
5
+ centOSにインストールしてあるPHPのバージョンはPHP 5.6.31です
4
6
 
5
7
 
6
8
 
7
- 次xserver

コードは下記cron設定にファのせて、実行ようと思っのですが、。
【2016年最新②】
9
+ 

コードは下記参考に致まし。
【2016年最新②】
8
10
 
9
- 行 1: ?php: そのようなファイルやディレクトリはありません
10
-
11
- 行 2: 予期しないトークン `'twitteroauth/autoload.php'' 周辺に構文エラーがあります
12
-
13
- 行 2: ` require_once('twitteroaut用のPHP作成とCron設定方法
h/autoload.php');'_cron/

11
+ TwitterBot用のPHP作成とCron設定方法
https://harublog.popnavi.net/programming/twitterbot_php_cron/

14
12
 
15
13
 
16
14
 
17
- とエラドして使っております
こちら出て、色々な方法を試しですが、。

15
+ twitterbotを動かす、PHPファイルはhttps://github.com/abraham/twitteroauth ここからダウンロドして使っております
こちら書いtwitter_bot.phpコードです。

18
-
19
- どれも上記のような通知メールが来ます。
20
16
 
21
17
 
22
18
 
19
+ twitter-bot-original1これがbotを動かす為のフォルダです
20
+
21
+ vagrantでの階層
22
+
23
+ /home/vagrant/twitter-bot-original1
24
+
25
+ twitter-bot-original1-config.php -twitter_bot.php
26
+
27
+ -config.php
28
+
29
+ -twitteroauth(これはディレクトリ)
30
+
31
+
32
+
33
+ twitter_bot.php
34
+
35
+ コード
36
+
37
+ **************************************************************
38
+
23
39
  <?php
24
40
 
25
- 行2 require_once('twitteroauth/autoload.php');
41
+ 行2 require_once('twitteroauth/autoload.php');
26
42
 
27
- 行3 require_once('twitteroauth/src/TwitterOAuth.php');
43
+ 行3 require_once('twitteroauth/src/TwitterOAuth.php');
28
44
 
29
- 行4 require_once(dirname(__FILE__) . '/config.php');
45
+ 行4 require_once(dirname(__FILE__) . '/config.php');
30
46
 
31
47
  use Abraham\TwitterOAuth\TwitterOAuth;
32
48
 
33
-  
34
49
 
35
- のようにコードは書いているのですが、何がおかしいでしょうか?
36
50
 
37
- 少しでもわかる方いればよろしくお願いいたします
51
+ $date = getdate();
38
52
 
39
53
 
40
54
 
41
- twitter-bot-original1
55
+ switch($date['wday']){
42
56
 
43
- -twitteroauth
57
+ case 0:
44
58
 
45
- config.php
59
+ $weekd = "日曜日";
46
60
 
47
- twitter_bot.php
61
+ case 1:
48
62
 
63
+ $weekd = "月曜日";
64
+
65
+ case 2:
66
+
67
+ $weekd = "火曜日";
68
+
69
+ case 3:
70
+
71
+ $weekd = "水曜日";
72
+
73
+ case 4:
74
+
75
+ $weekd = "木曜日";
76
+
77
+ case 5:
78
+
79
+ $weekd = "金曜日";
80
+
81
+ case 6:
82
+
83
+ $weekd = "土曜日";
84
+
85
+ }
86
+
87
+ //今日の残り日数
88
+
89
+ //$leave_today = 24 - $date['hours'];
90
+
91
+ //print "本日は残り"."$leave_today"."時間です"."\n";
92
+
93
+
94
+
95
+ $message = "現在は{$date['year']}年{$date['mon']}月{$date['mday']}日"."$weekd"."{$date['hours']}時{$date['minutes']}分です。"."\n";
96
+
97
+ //print $message;
98
+
99
+
100
+
101
+  // つぶやく
102
+
103
+ $connection = new TwitterOAuth(consumer_key, consumer_secret, access_token, access_token_secret);
104
+
105
+ $request = $connection->post("statuses/update", array("status"=> $message ));
106
+
107
+ ?>
108
+
109
+ ***************************************************
110
+
111
+
112
+
113
+ そこで、次にxserverのドメイン名の下のpublic_htmlにcentOSで実行できたtwitter-bot-original1をそのまま移動させて、
cron設定のコマンドに
114
+
115
+ 
/home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitter_bot.php
116
+
117
+ を書き込んで、コマンドを実行した事を知らせる為に
gmailを設定し、
118
+
119
+ 実行したところ


120
+
121
+ ・/home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitter_bot.php: 行 1: ?php: そのようなファイルやディレクトリはありません
122
+
123
+
124
+
125
+ ・/home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitter_bot.php: ・行 2: 予期しないトークン `'twitteroauth/autoload.php'' 周辺に構文エラーがあります
126
+
127
+
128
+
129
+ ・/home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitter_bot.php: 行 2: `    require_once('twitteroauth/autoload.php');'
130
+
49
- の階層で行なっております。
131
+ と言う文が返ってきて、
132
+
133
+
134
+
135
+ 
twitter_bot.phpの

136
+
137
+ <?php
138
+
139
+ require_once('twitteroauth/autoload.php');
140
+
141
+ require_once('twitteroauth/src/TwitterOAuth.php');
142
+
143
+ require_once(dirname(__FILE__) . '/config.php');
144
+
145
+ use Abraham\TwitterOAuth\TwitterOAuth;
146
+
147
+
148
+
149
+ 
のrequire_onceの部分でエラーが起こっていると思ったので、
150
+
151
+ 
1require_once(dirname(__FILE__) .'twitteroauth/autoload.php’);

152
+
153
+ 2require_once( __DIR__ . 'twitteroauth/autoload.php');
154
+
155
+ 3require_once( '/home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitteroauth/autoload.php');
156
+
157
+
158
+
159
+ 
1~3まで試したのですが、
160
+
161
+ 1だと 予期しないトークン `dirname' 周辺に構文エラーがあります
162
+
163
+ 2だと 予期しないトークン `__DIR__' 周辺に構文エラーがあります 

164
+
165
+ 3だと 予期しないトークン '/home/サーバーID/ドメイン名/public_html/twitter-bot-original1/twitteroauth/autoload.php' 周辺に構文エラーがあります
166
+
167
+
168
+
169
+ とgmailにエラー文が返信されてきます。
170
+
171
+ xserverのPHPバージョンは7.0.30です。
172
+
173
+ 
require_onceの構文に間違いがあると思うのですが、どこが問題だと思われますか?

174
+
175
+
176
+
177
+ 申し訳ありませんがよろしくお願い致します