Jump to content

InstagramMediaDisplay


nbcommunication
 Share

Recommended Posts

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

  • Like 3
  • Thanks 3
Link to comment
Share on other sites

  • 3 weeks later...

@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.

 

 

  • Like 1
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

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.

  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

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:

image.png.265e17e5551b598981ce8d58b6d9d283.png

And this it how it looks like on my website:

image.png.8b4d4f2ec4f2cb0cd855dc3ad3f93d2d.png

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

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

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.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...