title: Facebook page scraping
body: <p>I am trying to scrap a facebook page ( <a href="https://www.facebook.com/pages/PTSD/455847705426" rel="nofollow">https://www.facebook.com/pages/PTSD/455847705426</a> )
  I found this script to login to facebook.</p>
  
  <pre><code>&lt;?php
  $EMAIL = "me@mail.com";
  $PASSWORD = "facebookPassword";
  
  function cURL($url, $header=NULL, $cookie=NULL, $p=NULL)
  {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_HEADER, $header);
  curl_setopt($ch, CURLOPT_NOBODY, $header);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  
  if ($p) {
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
  }
  $result = curl_exec($ch);
  
  if ($result) {
  return $result;
  } else {
  return curl_error($ch);
  }
  curl_close($ch);
  }
  
  $a = cURL("https://login.facebook.com/login.php?login_attempt=1",true,null,"email=$EMAIL&amp;pass=$PASSWORD");
  preg_match('%Set-Cookie: ([^;]+);%',$a,$b);
  $c = cURL("https://login.facebook.com/login.php?login_attempt=1",true,$b[1],"email=$EMAIL&amp;pass=$PASSWORD");
  preg_match_all('%Set-Cookie: ([^;]+);%',$c,$d);
  for($i=0;$i&lt;count($d[0]);$i++)
  $cookie.=$d[1][$i].";";
  
  /*
  NOW TO JUST OPEN ANOTHER URL EDIT THE FIRST ARGUMENT OF THE FOLLOWING FUNCTION.
  TO SEND SOME DATA EDIT THE LAST ARGUMENT.
  */
  $page_html =  cURL("https://www.facebook.com/pages/PTSD/455847705426",null,$cookie,null);
  
  
  ?&gt;
  </code></pre>
  
  <p>now variable $page_html have only few posts, moreover they are in very complex code
  my questions are</p>
  
  <ol>
  <li>how can I get all posts.</li>
  <li>is there some other approach which return me complete and clear data.</li>
  <li>is there some way to have all posts in json format. </li>
  </ol>
  
  <p>please tell me if there is some useful tutorial or articles regarding this.</p>
  
  <p>Regards </p>