-2
I have the following code:
$username = 'makeup.pro.br';
$response = @file_get_contents( "https://www.instagram.com/$username/?__a=1" );
if ( $response !== false ) {
$data = json_decode( $response, true );
if ( $data !== null ) {
$full_name = $data['graphql']['user']['full_name'];
$follower = $data['graphql']['user']['edge_followed_by']['count'];
echo "{$full_name} have {$follower} followers.";
}
} else {
echo 'Username not found.';
}
die();
It works perfectly on localhost. But when I put it on the air, it brings nothing, it doesn’t work.
I can’t find the reason why it doesn’t work in the air.
Takes the
@
of@file_get_contents
. It makes no sense for you to omit any error message when you don’t know what is wrong.– Woss
I’ve done it. It didn’t work either.
– Maurício Biléssimo
Is there an error message in the server logs? What is the value of
$response
and$data
?– Woss
When I give an echo $Answer; on localhost, it brings me a json with the page information, but on the air, it just brings me a blank page with the Instagram symbol and nothing else. Could it be some configuration of my cloud server?
– Maurício Biléssimo
Instead of
echo
usevar_dump($response); exit;
– Woss
With var_dump, I returned this: string(38297) " "
– Maurício Biléssimo
Ok, now look at the source code of the page. It is returning an HTML or XML that the browser is trying to process.
– Woss
Trying to process an HTML: string(38304) "<! DOCTYPE html> <html lang="en" class="no-js not-logged-in client-root"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title> Login • Instagram </title> <meta name="robots" content="noimageindex, noarchive"> ...
– Maurício Biléssimo