Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
show amount of Instagram followers on website

It seems like Instagram has changed certain things, because I have tried several codes on my html website to show the amount of Instagram followers on a button, but nothing works.

I tried this:

<?php
$account='XXX';
$instagramsource=file_get_contents('https://instagram.com/' . $account);
preg_match_all('/"userInteractionCount":"(.*?)"/', $instagramsource, $count);
$followcount=$count[1][0];
echo "$account instagram account has $followcount followers";
?>

Also this

<?php
$otherPage = 'XXX';
$response = file_get_contents("https://www.instagram.com/$otherPage/?__a=1");
if ($response !== false) {
$data = json_decode($response, true);
if ($data !== null) {
    $follows = $data['graphql']['user']['edge_follow']['count'];
    $followedBy = $data['graphql']['user']['edge_followed_by']['count'];
    echo $follows . ' and ' . $followedBy;
}
}
?>

And this ...

<?php
$url = "https://www.instagram.com/XXX";
$json = file_get_contents($url);
$obj = json_decode($json, true);
$content = $obj['query']['results']['script']['content'];
$content = str_replace("window._sharedData =", "", $content);
$content = str_replace(";", "", $content);
$content = trim($content);
$json = json_decode($content);
$instagram_follower_count = $json->entry_data->ProfilePage{0}->user->followed_by->count;
?>

And finally this:

<?php
$username = 'XXX';
$response = @file_get_contents( "https://www.instagram.com/$username/?__a=1" );
if ( $response !== false ) {
$data = json_decode( $response, true );
if ( $data !== null ) {
    $follows = $data['graphql']['user']['edge_follow']['count'];
    $followedBy  = $data['graphql']['user']['edge_followed_by']['count'];
    echo 'XXX follows:' . $follows . ' and is followed by: ' . $followedBy;
}
}
?>                                                      

None works. Can anyone indicate what would work in 2021, please? Thanks.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

It's because the url https://www.instagram.com/$username/?__a=1 is redirecting to login page & giving u a html response

You can check it by echo $response

These posts will help you link1,link2

about 4 years ago · Juan Pablo Isaza Denunciar

0

Instagram blocked access via __a=1 parameter since 2018-04-12. __a=1 must be replaced by JS and Ajax bypass. I've looked for an alternative solution. You can use javascript code inside php. For example:

async function instagramFollowers () {
    
    const followers = []
    
    try {
        const userInfoSource = await Axios.get('https://www.instagram.com/123/')

        
        const jsonObject = userInfoSource.data.match(/<script type="text\/javascript">window\._sharedData = (.*)<\/script>/)[1].slice(0, -1)

        const userInfo = JSON.parse(jsonObject)
       
        const mediaArray = userInfo.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges.splice(0, 10)
        for (let media of mediaArray) {
            const node = media.node
            
            followers.push(node.thumbnail_src)
        }
    } catch (e) {
        console.error('Unable to retrieve Followers. Reason: ' + e.toString())
    }
    
    return followers
}

Other helpful links: how to write javascript code inside php

https://code.tutsplus.com/tutorials/how-to-use-ajax-in-php-and-jquery--cms-32494

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda