@@ -48,9 +48,23 @@ public function getData(Feed $feed): array
4848
4949 $ token = $ secrets ['token ' ];
5050
51- $ data = $ this ->getMentions ($ token , $ pageSize , $ configuration ['feeds ' ]);
51+ $ data = $ this ->getMentions ($ token , 1 , $ pageSize , $ configuration ['feeds ' ]);
5252
53- return array_map (fn (array $ item ) => $ this ->getFeedItemObject ($ item ), $ data );
53+ $ feedItems = array_map (fn (array $ item ) => $ this ->getFeedItemObject ($ item ), $ data );
54+
55+ $ result = [];
56+
57+ // Check that image is accessible, otherwise leave out the feed element.
58+ foreach ($ feedItems as $ feedItem ) {
59+ $ response = $ this ->client ->request (Request::METHOD_HEAD , $ feedItem ['mediaUrl ' ]);
60+ $ statusCode = $ response ->getStatusCode ();
61+
62+ if (200 == $ statusCode ) {
63+ $ result [] = $ feedItem ;
64+ }
65+ }
66+
67+ return $ result ;
5468 } catch (\Throwable $ throwable ) {
5569 $ this ->logger ->error ('{code}: {message} ' , [
5670 'code ' => $ throwable ->getCode (),
@@ -115,11 +129,11 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin
115129 return null ;
116130 }
117131
118- public function getMentions (string $ token , int $ pageSize = 10 , array $ searchProfileIds = []): array
132+ public function getMentions (string $ token , int $ page = 1 , int $ pageSize = 10 , array $ searchProfileIds = []): array
119133 {
120134 $ body = [
135+ 'page ' => $ page ,
121136 'pageSize ' => $ pageSize ,
122- 'page ' => 1 ,
123137 'searchProfileIds ' => $ searchProfileIds ,
124138 ];
125139
0 commit comments