nbcommunication Posted September 27 Share Posted September 27 Meta are disabling the Instagram Basic Display API on December 4th, 2024. After this point, the InstagramBasicDisplayApi module will no longer function. Meta do provide an API that can be used to access Instagram media, Instagram API with Instagram Login. Using this API I've been able to refactor InstagramBasicDisplayApi as a new module called InstagramMediaDisplay: https://github.com/nbcommunication/InstagramMediaDisplay The main caveat with using this module (and API) is that personal and/or private accounts cannot be used. If you try to generate an access token for a personal account, IG will prompt you to upgrade to a business account. As far as I'm aware this is still a free account, and the main limitation is that you cannot use licensed music in the same way you can on a personal account. I have access to various IG accounts, some personal, some business, and I've never noticed a difference. This new module is built to supersede InstagramBasicDisplayApi and its implementation is practically identical. Upgrading should simply be a case of installing, configuring your new Meta app, authorising the same account(s), and updating the call to the previous module to call this one: <?php // $instagram = $modules->get('InstagramBasicDisplayApi'); $instagram = $modules->get('InstagramMediaDisplay'); Cheers, Chris 3 3 Link to comment Share on other sites More sharing options...
Stefanowitsch Posted October 12 Share Posted October 12 @nbcommunication As the deadline of the 4th December is coming closer I started abandoning the old InstagramBasicDisplayApi module and using your new version. Thank you for releasing the new version!! I once again experienced that it is a real "pain" to set up an app via the Facebook Developer Account and then do the authorization for the instagram account that is going to be used. Maybe I am doing it wrong but I would like to ask how you - and the other users of this module - handle the authorization for client instagram accounts. Let me explain: 1. The client has a instagram account (so far so good...) 2. To make the integration possible: does the client have to set up an own facebook developer account and create the "Instagram App" inside this account by himself? To be honest, none of my clients is capable of doing this on their own. Thats why: 3. I am using my own facebook developer account to create the app 4. But then theres the authorization process for the instagram account: - You have to log in with the clients instagram credentials two times. Once to add the actual account and allow to fetch data from it. And second to generate a token. - Each time you log in with the credentials the two factor authorization method comes into place and sends a security code to the mobile phone of - the client! So basically you need to set everything up "together" with the client. And another problem: To be able to add the account to the facebook app in the first place you first have to add the clients instagram account to your facebook accounts center. Otherwise you won't be able to do any of the steps mentioned here in step 4! And this also does only work with two factor authentification. So therefore I am asking: How do you handle the integration process? I am using the InstagramBasicDisplayApi module in very few projects and I don't really have best-practice in setting up the integration yet. 1 Link to comment Share on other sites More sharing options...
nbcommunication Posted October 12 Author Share Posted October 12 Hi @Stefanowitsch, I've only rolled this out to clients where we already have access to the IG account. My expectation is that for the others we'll be doing it at a predetermined time with the client (e.g. a meeting) where they can provide us with temporary access (e.g. changing the password, then changing it back once we're done) and provide any auth codes if necessary. I agree, the process should be a lot simpler, and that's partly my approach to implementation and Meta's offering - I expect a simpler authentication process for the client would mean App Review for the developer and the headache involved with that. Cheers, Chris 1 Link to comment Share on other sites More sharing options...
Stefanowitsch Posted November 6 Share Posted November 6 I have a little update on this procedure: When disabling the two-factor authorization it is straight-forward and fast to add the customers instagram account into the app. First you don't have to ask the customer for the security code (on each login attempt) and second you don't need to add the clients instagram account to your facebook accounts center in the first place. When the app is working the client can feel free to re-activate the two-factor authorization. 3 Link to comment Share on other sites More sharing options...
Stefanowitsch Posted November 26 Share Posted November 26 Hi @nbcommunication, I have a question about rendering the description text of an instagram post. Right now i am printing out the text via the description property like this: <?= $item->description ?> Unfortunately the text formatting gets lost. Here is what the post looks like on instagram: And this it how it looks like on my website: I understand that this is what the Instagram API returns, but is there really no way of getting a formatted text in return? Link to comment Share on other sites More sharing options...
nbcommunication Posted November 26 Author Share Posted November 26 Hi, Unfortunately I discovered this morning that the token that is returned by the API expires after 60 days. This is the same as the previous API, but the documentation about generating tokens for this API didn't mention expiry or I wasn't aware of it while developing. Thankfully I've been able to use some of the code from the previous module for token renewal, and have released v1.1.0 of InstagramMediaDisplay which you need to upgrade to if you don't want an existing token to expire. It'll set the existing token to 'renews in 1 day' which triggers the token to be renewed on the next load. After this it should display in the module config as renews in 2 months. Once the token has 7 days left, it'll auto-renew. Cheers, Chris Link to comment Share on other sites More sharing options...
nbcommunication Posted November 26 Author Share Posted November 26 Hi @Stefanowitsch, Have you tried <?php nl2br($item->description); I expect the IG caption uses newlines, this would convert them to <br> tags. The module passes the caption through $sanitizer->entities1() which shouldn't remove the newlines as far as I'm aware. Cheers, Chris 1 Link to comment Share on other sites More sharing options...
Stefanowitsch Posted November 26 Share Posted November 26 49 minutes ago, nbcommunication said: Hi @Stefanowitsch, Have you tried <?php nl2br($item->description); I expect the IG caption uses newlines, this would convert them to <br> tags. The module passes the caption through $sanitizer->entities1() which shouldn't remove the newlines as far as I'm aware. Cheers, Chris Awesome! That was one easy fix. 1 Link to comment Share on other sites More sharing options...
benbyf Posted December 4 Share Posted December 4 Is there any working example links at all? Link to comment Share on other sites More sharing options...
nbcommunication Posted December 5 Author Share Posted December 5 Hi @benbyf, As in an example of this module working in production? Here's one if so: https://www.shetland.org/visit#block-links-21216 Cheers, Chris 1 Link to comment Share on other sites More sharing options...
Stefanowitsch Posted Tuesday at 04:04 PM Share Posted Tuesday at 04:04 PM @nbcommunication I recently updated on my site to make use of the new module version and it worked fine. Suddenly the feed is no longer displaying anything and I am getting this error message in the log files: Could not process user media: {"error":{"message":"Error validating access token: Session has expired on Saturday, 14-Dec-24 01:23:54 PST. The current time is Tuesday, 17-Dec-24 07:50:40 PST.","type":"OAuthException","code":190,"fbtrace_id":"ALq9x9hasK45lecwrhHmaep"}} I never faced this error before. I tried re-authorizing the account, generated a new token and placed it into the module settings but I keep getting this error message. EDIT: After a short period of time (i just checked again) the feed is working again. I don't know if re-authorizing was the solution but it seems that it worked in the end 🙂 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