title: Remote login to google
body: <p>I don't understand where is the problem on my code. when I try to login on google, its redirect me this page: <a href="https://support.google.com/accounts/answer/61416?co=GENIE.Platform%3DDesktop&amp;hl=en" rel="nofollow noreferrer">https://support.google.com/accounts/answer/61416?co=GENIE.Platform%3DDesktop&amp;hl=en</a></p>
  
  <p>I wants to login google then get back to <code>google.com</code>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  
  $useragent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36";
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://accounts.google.com/signin/v1/lookup");
  curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, 'Email=MY-EMAIL@gmail.com');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_exec($ch);
  
  
  curl_setopt($ch, CURLOPT_URL, "https://accounts.google.com/signin/challenge/sl/password?hl=en&amp;passive=true&amp;continue=https://www.google.com");
  curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, 'Passwd=MY-EMAIL-PASS');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, false);
  
  echo $output = curl_exec($ch);
  
  curl_close($ch);
  ?&gt;
  </code></pre>