Search code examples
phphtmlfacebooksimple-html-dom

PHP Simple HTML DOM Parser Brower no support (Facebook)


I'm using the PHP Simple HTML DOM Parser to get the contents of a facebook album just that the problem is returning and that I need to update my browser

My code

include('simple_html_dom.php');
$html = file_get_html("https://www.facebook.com/pg/natgeo/photos/?tab=album&album_id=431705768950");
echo $html;

Return this

enter image description here


Solution

  • Do it like this way !!

    $url = "https://www.facebook.com/pg/natgeo/photos/?tab=album&album_id=431705768950";
    
    $opts = array(
      'http'=>array(
        'header'=>"User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53\r\n"
      )
    );
    
    $context = stream_context_create($opts);
    $html = file_get_html($url , false, $context);