I have got one function which have code like this
$response = $this->request_validation($cookies, $fields);
$response_errors = json_decode($response, true)['errors'];
Its giving me warning called
Notice: Undefined index: errors in
I am not getting idea how I can handle this warning.
private function request_validation($cookies, $fields){
$headers = array();
$headers[] = 'Origin: https://login.yahoo.com';
$headers[] = 'X-Requested-With: XMLHttpRequest';
$headers[] = 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36';
$headers[] = 'content-type: application/x-www-form-urlencoded; charset=UTF-8';
$headers[] = 'Accept: */*';
$headers[] = 'Referer: https://login.yahoo.com/account/create?specId=yidReg&lang=en-US&src=&done=https%3A%2F%2Fwww.yahoo.com&display=login';
$headers[] = 'Accept-Encoding: gzip, deflate, br';
$headers[] = 'Accept-Language: en-US,en;q=0.8,ar;q=0.6';
$cookies_str = implode(' ', $cookies);
$headers[] = 'Cookie: '.$cookies_str;
$postdata = http_build_query($fields);
$url = $this->_yahoo_signup_ajax_url;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}
I am trying to fix it from last one and half hour but not getting idea for fix it. can anyone here please help me for resolve the issue. Thanks!