質問編集履歴
4
逆のテストパターンの結果を追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -69,6 +69,15 @@
|
|
69
69
|
$today: 2022-01-07 14:24:01
|
70
70
|
$unfollow_day:2022-01-07 13:01:31
|
71
71
|
のためtodayの方が新しい日付ですが
|
72
|
+
var_dump($today->gt($unfollow_day));
|
73
|
+
はfalseを
|
74
|
+
var_dump($today->lt($unfollow_day));
|
75
|
+
はtrueを返しています
|
76
|
+
|
77
|
+
また、$todayの日付の方が古いテストパターンも試しました
|
78
|
+
$today: 2022-08-30 22:54:48
|
79
|
+
$unfollow_day:2022-09-14 01:37:00
|
80
|
+
ところがこちらも
|
72
81
|
var_dump($today->gt($unfollow_day));
|
73
82
|
はfalseを
|
74
83
|
var_dump($today->lt($unfollow_day));
|
3
レスポンスの配列の情報を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,3 +78,174 @@
|
|
78
78
|
Laravel v8.83.23
|
79
79
|
PHP v7.4.18
|
80
80
|
|
81
|
+
|
82
|
+
### twitter APIからのレスポンス
|
83
|
+
https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-user_timeline
|
84
|
+
|
85
|
+
"created_at": "Thu Apr 06 15:28:43 +0000 2017",
|
86
|
+
を取得して比較に使用しています
|
87
|
+
|
88
|
+
```JSON
|
89
|
+
[
|
90
|
+
{
|
91
|
+
"created_at": "Thu Apr 06 15:28:43 +0000 2017",
|
92
|
+
"id": 850007368138018817,
|
93
|
+
"id_str": "850007368138018817",
|
94
|
+
"text": "RT @TwitterDev: 1/ Today we’re sharing our vision for the future of the Twitter API platform!nhttps://t.co/XweGngmxlP",
|
95
|
+
"truncated": false,
|
96
|
+
"entities": {
|
97
|
+
"hashtags": [],
|
98
|
+
"symbols": [],
|
99
|
+
"user_mentions": [
|
100
|
+
{
|
101
|
+
中略
|
102
|
+
}
|
103
|
+
],
|
104
|
+
"urls": [
|
105
|
+
{
|
106
|
+
中略
|
107
|
+
}
|
108
|
+
]
|
109
|
+
},
|
110
|
+
"source": "<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>",
|
111
|
+
"in_reply_to_status_id": null,
|
112
|
+
"in_reply_to_status_id_str": null,
|
113
|
+
"in_reply_to_user_id": null,
|
114
|
+
"in_reply_to_user_id_str": null,
|
115
|
+
"in_reply_to_screen_name": null,
|
116
|
+
"user": {
|
117
|
+
"id": 6253282,
|
118
|
+
"id_str": "6253282",
|
119
|
+
"name": "Twitter API",
|
120
|
+
"screen_name": "twitterapi",
|
121
|
+
"location": "San Francisco, CA",
|
122
|
+
"description": "The Real Twitter API. I tweet about API changes, service issues and happily answer questions about Twitter and our API. Don't get an answer? It's on my website.",
|
123
|
+
"url": "http://t.co/78pYTvWfJd",
|
124
|
+
"entities": {
|
125
|
+
"url": {
|
126
|
+
"urls": [
|
127
|
+
{
|
128
|
+
中略
|
129
|
+
}
|
130
|
+
]
|
131
|
+
},
|
132
|
+
"description": {
|
133
|
+
"urls": []
|
134
|
+
}
|
135
|
+
},
|
136
|
+
中略
|
137
|
+
},
|
138
|
+
"geo": null,
|
139
|
+
"coordinates": null,
|
140
|
+
"place": null,
|
141
|
+
"contributors": null,
|
142
|
+
"retweeted_status": {
|
143
|
+
"created_at": "Thu Apr 06 15:24:15 +0000 2017",
|
144
|
+
"id": 850006245121695744,
|
145
|
+
"id_str": "850006245121695744",
|
146
|
+
"text": "1/ Today we’re sharing our vision for the future of the Twitter API platform!nhttps://t.co/XweGngmxlP",
|
147
|
+
"truncated": false,
|
148
|
+
"entities": {
|
149
|
+
"hashtags": [],
|
150
|
+
"symbols": [],
|
151
|
+
"user_mentions": [],
|
152
|
+
"urls": [
|
153
|
+
{
|
154
|
+
中略
|
155
|
+
}
|
156
|
+
]
|
157
|
+
},
|
158
|
+
中略
|
159
|
+
"entities": {
|
160
|
+
"url": {
|
161
|
+
"urls": [
|
162
|
+
{
|
163
|
+
"url": "https://t.co/66w26cua1O",
|
164
|
+
"expanded_url": "https://dev.twitter.com/",
|
165
|
+
"display_url": "dev.twitter.com",
|
166
|
+
"indices": [
|
167
|
+
0,
|
168
|
+
23
|
169
|
+
]
|
170
|
+
}
|
171
|
+
]
|
172
|
+
},
|
173
|
+
"description": {
|
174
|
+
"urls": [
|
175
|
+
{
|
176
|
+
中略
|
177
|
+
}
|
178
|
+
]
|
179
|
+
}
|
180
|
+
},
|
181
|
+
中略
|
182
|
+
},
|
183
|
+
中略
|
184
|
+
},
|
185
|
+
中略
|
186
|
+
},
|
187
|
+
{
|
188
|
+
"created_at": "Mon Apr 03 16:09:50 +0000 2017",
|
189
|
+
"id": 848930551989915648,
|
190
|
+
"id_str": "848930551989915648",
|
191
|
+
"text": "RT @TwitterMktg: Starting today, businesses can request and share locations when engaging with people in Direct Messages. https://t.co/rpYn…",
|
192
|
+
"truncated": false,
|
193
|
+
"entities": {
|
194
|
+
"hashtags": [],
|
195
|
+
"symbols": [],
|
196
|
+
"user_mentions": [
|
197
|
+
{
|
198
|
+
中略
|
199
|
+
}
|
200
|
+
],
|
201
|
+
"urls": []
|
202
|
+
},
|
203
|
+
中略
|
204
|
+
"entities": {
|
205
|
+
"url": {
|
206
|
+
"urls": [
|
207
|
+
{
|
208
|
+
中略
|
209
|
+
}
|
210
|
+
]
|
211
|
+
},
|
212
|
+
"description": {
|
213
|
+
"urls": []
|
214
|
+
}
|
215
|
+
},
|
216
|
+
中略
|
217
|
+
},
|
218
|
+
中略
|
219
|
+
"entities": {
|
220
|
+
"hashtags": [],
|
221
|
+
"symbols": [],
|
222
|
+
"user_mentions": [],
|
223
|
+
"urls": [
|
224
|
+
{
|
225
|
+
中略
|
226
|
+
}
|
227
|
+
]
|
228
|
+
},
|
229
|
+
中略
|
230
|
+
"entities": {
|
231
|
+
"url": {
|
232
|
+
"urls": [
|
233
|
+
{
|
234
|
+
中略
|
235
|
+
}
|
236
|
+
]
|
237
|
+
},
|
238
|
+
"description": {
|
239
|
+
"urls": []
|
240
|
+
}
|
241
|
+
},
|
242
|
+
中略
|
243
|
+
},
|
244
|
+
中略
|
245
|
+
},
|
246
|
+
中略
|
247
|
+
}
|
248
|
+
]
|
249
|
+
|
250
|
+
```
|
251
|
+
|
2
回答をいただいて変更した実装を掲載しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,7 +42,37 @@
|
|
42
42
|
|
43
43
|
### 試したこと
|
44
44
|
|
45
|
+
回答をいただいて$unfollow_dayもcarbon化し、gtメソッドを使うようにしてみました
|
46
|
+
```PHP
|
47
|
+
$targetTweets = $twitter->get("statuses/user_timeline", $targetParameters);
|
48
|
+
$latestTweetTime = '';
|
49
|
+
foreach ($targetTweets as $target_tweet) {
|
50
|
+
$latestTweetTime = $target_tweet->created_at;
|
51
|
+
|
52
|
+
|
53
|
+
}
|
45
|
-
|
54
|
+
$today = Carbon::now();
|
55
|
+
$unfollow_day = new Carbon($latestTweetTime);
|
56
|
+
$unfollow_day = $unfollow_day->addDays(15);
|
57
|
+
$unfollow_day = $unfollow_day->addHours(9);
|
58
|
+
Log::debug($today->format('Y-m-d H:i:s'));
|
59
|
+
Log::debug($unfollow_day->format('Y-m-d H:i:s'));
|
60
|
+
var_dump($today->gt($unfollow_day));
|
61
|
+
var_dump($today->lt($unfollow_day));
|
62
|
+
if ($today->gt($unfollow_day)) {
|
63
|
+
Log::debug('到達確認');
|
64
|
+
$chk_flg = false;
|
65
|
+
}
|
66
|
+
```
|
67
|
+
|
68
|
+
ログに出力された日付は
|
69
|
+
$today: 2022-01-07 14:24:01
|
70
|
+
$unfollow_day:2022-01-07 13:01:31
|
71
|
+
のためtodayの方が新しい日付ですが
|
72
|
+
var_dump($today->gt($unfollow_day));
|
73
|
+
はfalseを
|
74
|
+
var_dump($today->lt($unfollow_day));
|
75
|
+
はtrueを返しています
|
46
76
|
|
47
77
|
### 補足情報(FW/ツールのバージョンなど)
|
48
78
|
Laravel v8.83.23
|
1
タグの順番を修正
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|