Instagram / PHP – Get Image Description

How to get the Instagram Image Description with PHP:

With this code you can define your own URL of an Instagram Post and print out the full Image Description.

$URL = $_POST['url'];

$ch=curl_init($URL);
curl_setopt_array($ch,array(
CURLOPT_ENCODING=>'',
CURLOPT_RETURNTRANSFER=>1
));
$html=curl_exec($ch);

$description=@DOMDocument::loadHTML($html)->getElementsByTagName("title")->item(0);
echo "<pre id='text'>";
$domd=@DOMDocument::loadHTML($html);
$xp=new DOMXPath($domd);
$json=$xp->query("//script[@type='application/ld+json']")->item(0)->textContent;
$data=json_decode($json,true);
$description=$data['caption'];
print_r($description);
echo "</pre>";

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Nach oben scrollen