Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用curl登录_Php_Session_Curl - Fatal编程技术网

Php 用curl登录

Php 用curl登录,php,session,curl,Php,Session,Curl,我尝试了,但无法使用以下代码登录。执行后,我再次显示登录页面。有人能帮我吗 $tmp_fname = tempnam("/tmp", "COOKIE"); $curl_handle = curl_init ("https://accessmanager.thy.com/amserver/UI/Login?goto=http%3A%2F%2Fwww2.thy.com%3A80%2Fuhkm"); curl_setopt ($curl_handle, CURLOPT_COOKIEJAR, $

我尝试了,但无法使用以下代码登录。执行后,我再次显示登录页面。有人能帮我吗

$tmp_fname = tempnam("/tmp", "COOKIE");

 $curl_handle = curl_init ("https://accessmanager.thy.com/amserver/UI/Login?goto=http%3A%2F%2Fwww2.thy.com%3A80%2Fuhkm");

 curl_setopt ($curl_handle, CURLOPT_COOKIEJAR, $tmp_fname);
 curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, true);

 $post_array = array('gx_charset' => 'UTF-8','encoded' => 'true', 'goto' => 'aHR0cDovL3d3dzIudGh5LmNvbTo4MC91aGtt','IDToken1' => 'XXXXXXXX', 'IDToken2' => 'XXXXXXXX');

 curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $post_array);

 $output = curl_exec ($curl_handle);

 $curl_handle = curl_init ("https://accessmanager.thy.com/amserver/UI/Login");
 curl_setopt ($curl_handle, CURLOPT_COOKIEFILE, $tmp_fname);
 curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);


 $output = curl_exec ($curl_handle);

 echo $output;  

您还需要遵循重定向:

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

卷发也不见了。