title: login to https site using curl
body: <p>i am trying to login to a site. this site use auto submit from and a random key for submitting form. i have tried several ways but couldn't get through. so here is my codes. any answer will be appreciated. thanks in advance. also my fake account pass and username available in code for those who wants to give a try. my url is little bit long </p>
  
  <pre><code>include 'simple_html_dom.php';
  $i = 0;
  $html = file_get_html($url);
  foreach($html-&gt;find('input') as $keys) {
      $ltkey = $keys-&gt;value;
      if (++ $i == 1)
          break;
  }
  $url = 'https://auth.station.sony.com/login?theme=poxnora&amp;cid=1056360&amp;service=https://poxnora.station.sony.com/cas/merge.do&amp;regService=https://poxnora.station.sony.com /play/load.do';
  $data = 'lt=' . $ltkey . '&amp;_eventId=submit&amp;username=XXXXXXXX&amp;password=XXXXXXXX';
  
  // curl request
  $fp = fopen("cookie.txt", "w");
  fclose($fp);
  $login = curl_init();
  curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
  curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
  curl_setopt($login, CURLOPT_TIMEOUT, 40000);
  curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($login, CURLOPT_URL, $url);
  curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
  curl_setopt($login, CURLOPT_POST, TRUE);
  curl_setopt($login, CURLOPT_POSTFIELDS, $data);
  curl_setopt($login, CURLOPT_SSL_VERIFYPEER, TRUE);
  curl_setopt($login, CURLOPT_SSL_VERIFYHOST, 2);
      curl_setopt($login, CURLOPT_CAINFO, "cert.crt");
  $result = curl_exec($login);
  curl_close($login);
  
  echo $result;
  </code></pre>