DV-JF Posted February 3 Share Posted February 3 Hey @nbcommunication, hey all... since a few day's (don't know exactly when it startet) I've a problem getting the feed. I'm using this plugin on different sites with various accounts - so far had no problems with it. On 3 of these websites the feed doesn't load any more - on the other websites I suspect that the cache is not expired, yet. There are no items in the $instagram->getMedia() array any more - no errors are shown. When I review the modules settings this so what I got: There is currently 1 cached request. Clearing the cache doesn't help. Anyone else facing this problem, any ideas how I could debug further? Cheers and many greet! Link to comment Share on other sites More sharing options...
nbcommunication Posted February 3 Author Share Posted February 3 Hi @DV-JF, Is there anything in Setup -> Logs? Cheers, Chris 1 Link to comment Share on other sites More sharing options...
DV-JF Posted February 3 Share Posted February 3 Indeed - didn't thought about this place to look for errors 🤦♂️ vor 8 Minuten 2023-02-03 09:29:01 guest / Could not process user media: {"error":{"message":"Error validating access token: The session has been invalidated because the user changed their password or Facebook has changed the session for security reasons.","type":"OAuthException","code":190,"fbtrace_id":"A8JC4GfQtIPWPBs_P8YONKd"}} vor 8 Minuten 2023-02-03 09:29:01 guest / Could not refresh long-lived access token I expected the access token to be renewed automatically - the passwords of the corresponding pages were not changed. Link to comment Share on other sites More sharing options...
nbcommunication Posted February 3 Author Share Posted February 3 Hi @DV-JF, Ah yes, this is a total pain when this happens. We've had this happen on sites where we don't have much contact with the client, as since we need them to re-authorise, the feed is just lying empty. Anyway, going through the authorisation process again should fix this. Cheers, Chris Link to comment Share on other sites More sharing options...
DV-JF Posted February 3 Share Posted February 3 27 minutes ago, nbcommunication said: Ah yes, this is a total pain when this happens. Can you tell me why it happens? Would it be possible to send an email to the admin, if the authentication process fails - any ideas? Link to comment Share on other sites More sharing options...
nbcommunication Posted February 3 Author Share Posted February 3 Hi @DV-JF, It happens because Instagram/Facebook invalidates the (authorised) access token if the user changes their password. I guess from the error message (Facebook has changed the session for security reasons) other security issues can lead to it happening too. It isn't in the scope of the module to notify admins, but it should be pretty easy to implement. Try something like: <?php $instagram = $modules->get('InstagramBasicDisplayApi'); $items = $instagram->getMedia(); if(!($items instanceof WireArray) || !$items->count) { $cache->getFor($instagram, 'errorNotifyAdmin', 'daily', function() use ($config, $instagram, $log, $mail) { return $mail->new() ->to($config->adminEmail) ->subject("$instagram error") ->bodyHTML('<p>' . implode('<br>', $log->getLines( $instagram->className(['lowercase' => true]), ['limit' => 10] )) . '</p>') ->send(); }); } This would send the admin an email every day if no media is being returned, with the email being the last 10 log messages. Cheers, Chris 1 Link to comment Share on other sites More sharing options...
DV-JF Posted February 3 Share Posted February 3 WOW, thanks for your detailed answer and the code example @nbcommunication That's why I like the PW community so much !!! Is there any way I can support you, would like to spend you a 🍻 or ☕ Link to comment Share on other sites More sharing options...
nbcommunication Posted February 3 Author Share Posted February 3 Hi @DV-JF, Thanks but no need, I'm always glad to hear that the module is getting used! Cheers, Chris Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now