set_time_limit(0);

$php_userid = 'lepinoux78';
$php_password ='lafayette';


$cookie_file_path = "cookie.txt"; // Please set your Cookie File path
$fp = fopen($cookie_file_path,'w');
//$fp = fopen($cookie_file_path,'wb');
fclose($fp);
$agent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36";
//$reffer = "http://ichart.finance.yahoo.com/table.csv?s=DDD&a=11&b=4&c=2013&d=11&e=6&f=2013";
$reffer = "https://login.yahoo.co.jp/config/login?.lg=jp&.intl=jp&logout=1&.src=auc&.done=https%3A%2F%2Fauctions.yahoo.co.jp%2F";
/*
// log out.
$LOGINURL = "http://us.ard.yahoo.com/SIG=12hoqklmn/M=289534.5473431.6553392.5333790/D=mail/S=150500014:HEADR/Y=YAHOO/EXP=1135053978/A=2378664/R=4/SIG=133erplvs/*http://login.yahoo.co.jp/config/login?logout=1&.done=http://ichart.finance.yahoo.com/table.csv?s=DDD&a=11&b=4&c=2013&d=11&e=6&f=2013";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
//curl_setopt($ch, CURLOPT_PROXY, '206.221.182.74:2083');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
echo curl_error($ch);
curl_close ($ch);
sleep(10);
*/
//1. Get first login page to parse hash_u,hash_challenge https://auctions.yahooapis.jp/AuctionWebService/V

$LOGINURL = "https://login.yahoo.co.jp/config/login";
//$LOGINURL='https://auctions.yahooapis.jp/AuctionWebService/V';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
//curl_setopt($ch, CURLOPT_PROXY, '206.221.182.74:2083');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$loginpage_html = curl_exec ($ch);
$bid_inputs = get_inputs($loginpage_html);
$bid_inputs['auth_method']='pwd';
$bid_inputs['user_name']='lepinoux78';
$bid_inputs['fido']=0;
$bis_inputs['auth_list']="pwd";
$bis_inputs['login']="lepinoux78";
$bid_inputs['passwd']="lafayette";
//$bid_inputs['captchaForm']="0";
//$bid_inputs['validate']="validate";
//$bid_inputs['.sectry']="0";
print_r($bid_inputs);
//echo $loginpage_html;
echo curl_error($ch);
curl_close ($ch);

preg_match_all("/name=\".u\" value=\"(.*?)\"/", $loginpage_html, $arr_hash_u);
preg_match_all("/name=\".challenge\" value=\"(.*?)\"/", $loginpage_html, $arr_hash_challenge);

//$hash_u = $arr_hash_u[1][0];
//$hash_challenge = $arr_hash_challenge[1][0];


//.tries=1&.src=auc&.last=http%3A%2F%2Flogin.yahoo.co.jp%2Fconfig%2Fedit_auc&promo=&.intl=jp&.bypass=&.partner=&.u=cq4ce2ov02mdi&.v=0&.fUpdate=Y&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fuser.auctions.yahoo.co.jp%2Fjp%2Fshow%2Fmystatus&login=********&passwd=***********
// 2- Post Login Data to Page https://login.yahoo.com/config/login?
sleep(5);
$LOGINURL = "https://login.yahoo.co.jp/config/login";

$POSTFIELDS = '.ct=^&.display=^&.done=https^%^3A^%^2F^%^2Fauctions.yahoo.co.jp^%^2F^&.keep=^&.reg=https^%^3A^%^2F^%^2Faccount.edit.yahoo.co.jp^%^2Fregistration^%^3Fsrc^%^3Dauc^%^26done^%^3Dhttps^%^253A^%^252F^%^252Fauctions.yahoo.co.jp^%^252F^%^26sr_required^%^3Dbirthday^%^2Bgender^%^2Bpostcode^%^2Bdeliver^&.src=auc^&.suppreg_skip=^&.yby=^&auth_lv=pw^&card_cushion_skip=^&ckey=^&nolink=^&nonotice=^&noreg=^&referrer=^&t_cushion=^&.albatross=dD1NdlYzYkImc2s9Ti5WMmtXYnVUek5pUmFYcXhweENyYWN0cjFRLQ^%^3D^%^3D^&.requiredPsCheckBox=^&.slogin=^&.tries=1^&ls_autocomp=^&showpw_status=^&u=cfd9pl5dtqmuc^&inactive_pw=^&version=^&auth_method=pwd^&pwless_captchaid=^&masked_dest=^&bcrumb_id_check=dD1NdlYzYkImc2s9cGJQeFlCNGdzQ1VWN2NKZkNqSkcyYnZYTUNFLQ^%^3D^%^3D^&bcrumb_send_sms=dD1NdlYzYkImc2s9VGFhLllHVjFpd01ZX1ViOHFEQVdPekg1dzZjLQ^%^3D^%^3D^&bcrumb_send_mail=dD1NdlYzYkImc2s9c012TFNJVkVLZU92OFJJRzdjRW9qMW84WGxnLQ^%^3D^%^3D^&user_name=lepinoux78^&sms_push=^&assertionInfo=^&webauthn=^&fido=0^&auth_list=pwd^&login=lepinoux78^&passwd=lafayette^&code=^&btnSubmit=^&.persistent=y^&yjbfp_items=ua^%^02Mozilla^%^2F5.0+^%^28Windows+NT+6.3^%^3B+Win64^%^3B+x64^%^29+AppleWebKit^%^2F537.36+^%^28KHTML^%^2C+like+Gecko^%^29+Chrome^%^2F70.0.3538.77+Safari^%^2F537.36^%^01lang^%^02en-US^%^01screen_height^%^02768^%^01screen_width^%^021366^%^01timezone_offset^%^02-330^%^01plugins^%^02Chrome+PDF+Plugin^%^7CChrome+PDF+Viewer^%^7CNative+Client^%^01canvas_image^%^02iVBORw0KGgoAAAANSUhEUgAAABAAAAAWCAYAAADJqhx8AAAByUlEQVQ4T9WUv0vDUBSFv1AsaHUSxCylEmsddXGTgiJ2UhcFsY4OpaCIuLo4OQn^%^2BDw61ILgFpJPoIDg4OLTWWlJKgqBYtFGMEnlP6s9apYrgnV6Sdw^%^2F3OznvKfywFNHvuhtuvTr^%^2FSGB9HXZ2YHUVGhtfgP8eYX^%^2FfxDCuGBnR8Ho9PE^%^2BwvOxSLCpvRnw99ubmFwi7uy7xOCQSCqEQ3NzA^%^2FDz098PUFHzpwfm52OgSDucJBh26uzUWFjysrUGpZKLrVxSLGtPTZ1hWFQThq8AoFC7p6TFoaOjk4MDHysoD29snGEYLmYxKNGp^%^2BLpBOw9zcHUNDGdLpVsJhlcHBMrqex3ECUrCmQIVbVU85OnJYWtKw7TPpum1r7O15agsIDGFWPF5mYiLP4qKfw0MTv7^%^2BF42NVBqnmBEJAYExO3jM2lmNgoIlstkQkEiCV8n1fYHYWYjGTQsFCVX0yNMmk53sCAiGXc5mZsdnaytLb20Zfnyr^%^2FkKjhYat6Eis5ePJBwXGe3A^%^2BFAsRiTbJZhExkomqU318oIvMXF7dEIh1vPun6qXyuvP9wGq^%^2Bv70gmM3LT^%^2BHgXzc1eubasskQSNTraSXu7T65^%^2F5zjXex^%^2BKvkcATSsyIKf0dAAAAABJRU5ErkJggg^%^3D^%^3D';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
//curl_setopt($ch, CURLOPT_PROXY, '206.221.182.74:2083');
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($bid_inputs));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);
//echo curl_error($ch);
//fclose($fp);
print_r($result);