Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
mostrar la cantidad de seguidores de Instagram en el sitio web

Parece que Instagram ha cambiado ciertas cosas, porque probé varios códigos en mi sitio web html para mostrar la cantidad de seguidores de Instagram en un botón, pero nada funciona.

Intenté esto:

 <?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"; ?>

También esto

 <?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; } } ?>

Y esto ...

 <?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; ?>

Y finalmente esto:

 <?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; } } ?>

Ninguno funciona. ¿Alguien puede indicar qué funcionaría en 2021, por favor? Gracias.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Es porque la URL https://www.instagram.com/$username/?__a=1 está redirigiendo a la página de inicio de sesión y dando una respuesta html

Puedes comprobarlo mediante echo $response

Estas publicaciones te ayudarán link1 , link2

about 4 years ago · Juan Pablo Isaza Report

0

Instagram bloqueó el acceso a través del parámetro __a=1 desde el 12 de abril de 2018. __a=1 debe ser reemplazado por JS y Ajax bypass. He buscado una solución alternativa. Puede usar código javascript dentro de php. Por ejemplo:

 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 }

Otros enlaces útiles: cómo escribir código javascript dentro de php

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!