Php 无法获取instagram显示图片链接

Php 无法获取instagram显示图片链接,php,Php,我一直在努力实现这一目标, 因此,我试图创建一个代码来获取任何instagram帐户显示图片链接,我只需要图片的链接,而不需要下载图片 $url = "https://instagram.com/+ $instagram"; $content = file_get_contents($url); // M-jxE is the div id of any profile photo on Instagram website $first_step = explode( '<div id="

我一直在努力实现这一目标, 因此,我试图创建一个代码来获取任何instagram帐户显示图片链接,我只需要图片的链接,而不需要下载图片

$url = "https://instagram.com/+ $instagram";
$content = file_get_contents($url);
// M-jxE is the div id of any profile photo on Instagram website
$first_step = explode( '<div id="M-jxE">' , $content );
$second_step = explode("</div>" , $first_step[1] );

echo $second_step[0];
$url=”https://instagram.com/+$instagram”;
$content=file\u get\u contents($url);
//M-jxE是Instagram网站上任何个人资料照片的部门id
$first_step=分解(“”,$content);
$second_step=explode(“,$first_step[1]);
echo$second_步骤[0];
试试这段代码

<?
$url = "https://instagram.com/ares566";
$content = file_get_contents($url);
preg_match('/og:image.*" content="(.*)"/ui',$content,$a);
echo $a[1];

您确定$url正确吗?它看起来不像instagram帐户。尝试使用
”https://instagram.com/$instagram“
。但我认为不可能拍到这样的照片<代码>“
将发生您无法预料的变化。您必须使用instagram API:$instagram是存储在我数据库中的instagram用户名,当我回显它时,它工作正常。我很高兴!请记下我的答案;)