| Recommend this page to a friend! |
| PHP HTTP protocol client | > | All threads | > | authentication error: the requested... | > | (Un) Subscribe thread alerts |
| |||||||||||||||
| 1 - 10 | 11 - 11 |
authentication error: the requested credential user is not defined
I am receiving this response only sometimes when i run this not every time. I am using http.php and included sasl.php and all the sasl library files are present. Can anyone see why this code might not be working? <?php require_once("http.php"); include('sasl.php'); function http_get( $url ) { $returnvalue = ""; set_time_limit(0); $http=new http_class; $http->timeout=0; $http->data_timeout=0; $http->debug=0; $http->html_debug=0; $http->follow_redirect=1; $http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; $error=$http->GetRequestArguments($url,$arguments); $arguments["RequestMethod"]="GET"; $error=$http->Open($arguments); if($error) die($error); $error=$http->SendRequest($arguments); if($error) die($error); $headers=array(); $error=$http->ReadReplyHeaders(&$headers); if($error) die($error); for(;;) { $error=$http->ReadReplyBody($body,1000); if ($error!="" || strlen($body)==0) break; $returnvalue .= $body; } return $returnvalue; } function targus_validate( $fields ) { $returnvalue = 999; $reject_codes=array(1, 9, 10, 13, 15, 16, 17, 20, 22, 24, 25, 26, 27, 29, 30, 31); $fields['phone'] = str_replace("-", "", $fields['phone']); $url = "https://gwydemo.targusinfo.com/access/query?svcid=9212807267&username=Username&password=PASS&elems=3221"; if (isset($fields['phone'])) $url .= "&key1=".urlencode($fields['phone']); if (isset($fields['email'])) $url .= "&key572=".$fields['email']; if (isset($fields['address'])) $url .= "&key1390=".urlencode($fields['address']); if (isset($fields['city'])) $url .= "&key1391=".urlencode($fields['city']); if (isset($fields['state'])) $url .= "&key1392=".urlencode($fields['state']); if (isset($fields['zip'])) $url .= "&key1393=".urlencode($fields['zip']); if (isset($fields['name'])) $url .= "&key1395=".urlencode($fields['name']); $url .= "&key3221=1,2,3,4,5,6,19,8,20,21,22,23,24,25,26,10,11,14,27,28,29,30,31"; $url .= "&key3298=13"; $body = http_get( $url ); $reg_error = "<errorcode>(.*)<\/errorcode>"; $reg_value = "<value>(.*)<\/value>"; if( preg_match("/$reg_error/siU", $body, $matches) && (trim($matches[1]) == 0) ) { if(preg_match("/$reg_value/siU", $body, $matches)) { $values = explode(",", trim($matches[1])); $value = $values[2]; if (in_array($value, $reject_codes)) { $returnvalue = $value; } else { $returnvalue = 0; } } } else { if ( preg_match("/$reg_error/siU", $body, $matches) ) { $returnvalue = trim($matches[1]); } } return $returnvalue; } ?> HTTP/1.1 200 OK Connection: close Date: Mon, 25 Feb 2008 19:35:02 GMT Server: Apache/2.2.6 (Fedora) Content-Length: 66 Content-Type: text/plain Client-Date: Mon, 25 Feb 2008 19:35:03 GMT Client-Peer: 208.109.29.56:80 Client-Response-Num: 1 X-Powered-By: PHP/5.2.4 authentication error: the requested credential user is not defined
It seems you are accessing a page that requires authentication but you are not specifying the user and password.
After calling GetRequestArguments() function, you need to set the user and password like this: $arguments["AuthUser"]="some user"; $arguments["AuthPassword"]="some password";
That did the trick. Thanks so much!
I am now sometimes getting this response from a different file:
Could not process the SASL authentication step: Basic authentication was finished without success <?php require_once("http.php"); include( 'sasl.php' ); function http_get( $url ) { $returnvalue = ""; set_time_limit(0); $http=new http_class; $http->timeout=0; $http->data_timeout=0; $http->debug=0; $http->html_debug=0; $http->follow_redirect=1; $http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; $error=$http->GetRequestArguments($url,$arguments); $arguments["AuthUser"]="Username"; $arguments["AuthPassword"]="Password"; $arguments["RequestMethod"]="GET"; $error=$http->Open($arguments); if($error) die($error); $error=$http->SendRequest($arguments); if($error) die($error); $headers=array(); $error=$http->ReadReplyHeaders(&$headers); if($error) die($error); for(;;) { $error=$http->ReadReplyBody($body,1000); if ($error!="" || strlen($body)==0) break; $returnvalue .= $body; } return $returnvalue; } function targus_validate( $fields ) { $returnvalue = 32; $reject_codes=array(1, 9, 10, 13, 15, 16, 17, 20, 22, 26, 27, 29, 30, 31); $fields['phone'] = str_replace("-", "", $fields['phone']); $url = "https://gwydemo.targusinfo.com/access/query?svcid=9212807267&username=GetSeenMedia&password=aYmh4Ch8&elems=3221"; if (isset($fields['phone'])) $url .= "&key1=".urlencode($fields['phone']); if (isset($fields['email'])) $url .= "&key572=".$fields['email']; if (isset($fields['address'])) $url .= "&key1390=".urlencode($fields['address']); if (isset($fields['city'])) $url .= "&key1391=".urlencode($fields['city']); if (isset($fields['state'])) $url .= "&key1392=".urlencode($fields['state']); if (isset($fields['zip'])) $url .= "&key1393=".urlencode($fields['zip']); if (isset($fields['name'])) $url .= "&key1395=".urlencode($fields['name']); $url .= "&key3221=1,2,3,4,5,6,19,8,20,21,22,23,24,25,26,10,11,14,27,28,29,30,31"; $url .= "&key3298=13"; $body = http_get( $url ); $reg_error = "<errorcode>(.*)<\/errorcode>"; $reg_value = "<value>(.*)<\/value>"; if( preg_match("/$reg_error/siU", $body, $matches) && (trim($matches[1]) == 0) ) { if(preg_match("/$reg_value/siU", $body, $matches)) { $values = explode(",", trim($matches[1])); $value = $values[2]; if (in_array($value, $reject_codes)) { $returnvalue = $value; } else { $returnvalue = 0; } } } else { if ( preg_match("/$reg_error/siU", $body, $matches) ) { $returnvalue = trim($matches[1]); } } return $returnvalue; } ?>
I am now getting this error sometimes but not every time.
authentication error: the requested credential user is not defined <?php require_once("http.php"); function http_get( $url ) { $returnvalue = ""; set_time_limit(0); $http=new http_class; $http->timeout=0; $http->data_timeout=0; $http->debug=0; $http->html_debug=0; $http->follow_redirect=1; $http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; $error=$http->GetRequestArguments($url,$arguments); $arguments["AuthUser"]="Username"; $arguments["AuthPassword"]="Password"; $arguments["RequestMethod"]="GET"; $error=$http->Open($arguments); if($error) die($error); $error=$http->SendRequest($arguments); if($error) die($error); $headers=array(); $error=$http->ReadReplyHeaders(&$headers); if($error) die($error); for(;;) { $error=$http->ReadReplyBody($body,1000); if ($error!="" || strlen($body)==0) break; $returnvalue .= $body; } return $returnvalue; } function targus_validate( $fields ) { $returnvalue = 32; $reject_codes=array(1, 9, 10, 13, 15, 16, 17, 20, 22, 26, 27, 29, 30, 31); $fields['phone'] = str_replace("-", "", $fields['phone']); $url = "https://gwydemo.targusinfo.com/access/query?svcid=9212807267&username=Username&password=Password&elems=3221"; if (isset($fields['phone'])) $url .= "&key1=".urlencode($fields['phone']); if (isset($fields['email'])) $url .= "&key572=".$fields['email']; if (isset($fields['address'])) $url .= "&key1390=".urlencode($fields['address']); if (isset($fields['city'])) $url .= "&key1391=".urlencode($fields['city']); if (isset($fields['state'])) $url .= "&key1392=".urlencode($fields['state']); if (isset($fields['zip'])) $url .= "&key1393=".urlencode($fields['zip']); if (isset($fields['name'])) $url .= "&key1395=".urlencode($fields['name']); $url .= "&key3221=1,2,3,4,5,6,19,8,20,21,22,23,24,25,26,10,11,14,27,28,29,30,31"; $url .= "&key3298=13"; $body = http_get( $url ); $reg_error = "<errorcode>(.*)<\/errorcode>"; $reg_value = "<value>(.*)<\/value>"; if( preg_match("/$reg_error/siU", $body, $matches) && (trim($matches[1]) == 0) ) { if(preg_match("/$reg_value/siU", $body, $matches)) { $values = explode(",", trim($matches[1])); $value = $values[2]; if (in_array($value, $reject_codes)) { $returnvalue = $value; } else { $returnvalue = 0; } } } else { if ( preg_match("/$reg_error/siU", $body, $matches) ) { $returnvalue = trim($matches[1]); } } return $returnvalue; } ?>
I am now getting this error sometimes.
Could not process the SASL authentication step: Basic authentication was finished without success <?php require_once("http.php"); function http_get( $url ) { $returnvalue = ""; set_time_limit(0); $http=new http_class; $http->timeout=0; $http->data_timeout=0; $http->debug=0; $http->html_debug=0; $http->follow_redirect=1; $http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; $error=$http->GetRequestArguments($url,$arguments); $arguments["AuthUser"]="Username"; $arguments["AuthPassword"]="Password"; $arguments["RequestMethod"]="GET"; $error=$http->Open($arguments); if($error) die($error); $error=$http->SendRequest($arguments); if($error) die($error); $headers=array(); $error=$http->ReadReplyHeaders(&$headers); if($error) die($error); for(;;) { $error=$http->ReadReplyBody($body,1000); if ($error!="" || strlen($body)==0) break; $returnvalue .= $body; } return $returnvalue; } function targus_validate( $fields ) { $returnvalue = 32; $reject_codes=array(1, 9, 10, 13, 15, 16, 17, 20, 22, 26, 27, 29, 30, 31); $fields['phone'] = str_replace("-", "", $fields['phone']); $url = "https://gwydemo.targusinfo.com/access/query?svcid=9212807267&username=Username&password=Password&elems=3221"; if (isset($fields['phone'])) $url .= "&key1=".urlencode($fields['phone']); if (isset($fields['email'])) $url .= "&key572=".$fields['email']; if (isset($fields['address'])) $url .= "&key1390=".urlencode($fields['address']); if (isset($fields['city'])) $url .= "&key1391=".urlencode($fields['city']); if (isset($fields['state'])) $url .= "&key1392=".urlencode($fields['state']); if (isset($fields['zip'])) $url .= "&key1393=".urlencode($fields['zip']); if (isset($fields['name'])) $url .= "&key1395=".urlencode($fields['name']); $url .= "&key3221=1,2,3,4,5,6,19,8,20,21,22,23,24,25,26,10,11,14,27,28,29,30,31"; $url .= "&key3298=13"; $body = http_get( $url ); $reg_error = "<errorcode>(.*)<\/errorcode>"; $reg_value = "<value>(.*)<\/value>"; if( preg_match("/$reg_error/siU", $body, $matches) && (trim($matches[1]) == 0) ) { if(preg_match("/$reg_value/siU", $body, $matches)) { $values = explode(",", trim($matches[1])); $value = $values[2]; if (in_array($value, $reject_codes)) { $returnvalue = $value; } else { $returnvalue = 0; } } } else { if ( preg_match("/$reg_error/siU", $body, $matches) ) { $returnvalue = trim($matches[1]); } } return $returnvalue; } ?>
That means that the user name or password are wrong.
The lines to set the parameters $arguments["AuthUser"] and $arguments["AuthPassword"] were just an example. You need to change the "UserName" to the real user name and "Password" to the real password of that user.
yes i am using the correct username and password but changed it for posting purposes.
I only get that response sometimes and some other times it works. I am using the correct username and password as was provided to me though, I'll check and make sure.
You need to tell me what are you doing different in the times it does not work.
That's the thing i am doing nothing different. I run the php file with the same arguments a bunch of times and sometimes it works as expected and others it gives me that response.
|
| 1 - 10 | 11 - 11 |
info at phpclasses dot org.
