diff --git a/classes/InstagramService.php b/classes/InstagramService.php index b48932c..9ef450b 100644 --- a/classes/InstagramService.php +++ b/classes/InstagramService.php @@ -90,8 +90,12 @@ class InstagramService extends SocialService { $posts = json_decode((string) $response->getBody(), true)['data']; foreach ($posts as $post) { + if (!data_get($post, 'caption')) { + continue; + } + yield [ - 'message' => $post['caption'], + 'message' => data_get($post, 'caption', ''), 'remote_id' => $post['id'], 'href' => $post['permalink'], 'created_at' => Carbon::parse($post['timestamp']), diff --git a/formwidgets/InstagramLogin.php b/formwidgets/InstagramLogin.php index b0fddd3..81d403f 100644 --- a/formwidgets/InstagramLogin.php +++ b/formwidgets/InstagramLogin.php @@ -64,7 +64,7 @@ class InstagramLogin extends FormWidgetBase { $me = app(InstagramService::class)->me($accessToken); - Page::create([ + Page::updateOrCreate(['remote_id' => $me['id']], [ 'access_token' => $accessToken, 'type' => app(InstagramService::class)->getType(), 'name' => $me['username'],