fork download
  1. <?php
  2.  
  3. $html = "<html><head><meta property=\"al:ios:url\" content=\"instagram://media?id=1329656989202933577\" /></head><body><span/></body></html>";
  4. $dom = new DOMDocument('1.0', 'UTF-8');
  5. $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
  6.  
  7. $xpath = new DOMXPath($dom);
  8. $metas = $xpath->query('//meta[@property="al:ios:url"]');
  9. $id = "";
  10. if (preg_match('~[?&]id=(\d+)~', $metas->item(0)->getAttribute('content'), $match))
  11. {
  12. $id = $match[1];
  13. }
  14. echo $id;
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
1329656989202933577