$lastDate) && !$itemData['is_self']) { $post = new BlogPost(); $post->link = $itemData['url']; $post->title = $itemData['title']; $post->category = $itemData['subreddit']; $post->nsfw = $itemData['over_18']; array_push($statuses, $post); if (!$first_article) { $myfile = fopen($file, 'w') or die('Unable to open file!'); fwrite($myfile, $ts); fclose($myfile); $first_article = true; } } } $statuses = array_reverse($statuses); $mastodon = new MastodonAPI($token, $base_url); foreach ($statuses as $s) { $status_data = [ 'visibility' => $visibility, 'language' => $language, ]; $statusText = $s->title.$tagline.$s->link.' '; if ($s->nsfw) { $status_data['status'] = 'NSFW'; $status_data['spoiler_text'] = $statusText; } else { $status_data['status'] = $statusText; } $mastodon->postStatus($status_data); } class BlogPost { public $ts; public $link; public $category; public $title; public $nsfw; }