Re: [PHP] Help with sending credentials?

2010-10-15 Thread Richard Quadling
On 14 October 2010 21:45, Brian Dunning br...@briandunning.com wrote:
 Gents -

 I'm trying to work with a major vendor's web service, but all my efforts are 
 met with a 401 authentication error response. I can log in manually to this 
 URL using these credentials through a browser, so I know the credentials are 
 good. Unfortunately the support guys at the vendor don't see any problem with 
 my code and have not been able to help.

 $url = https://servername.com/script;;
 $ctx = stream_context_create(array('https' = array(
        'timeout' = 10,
        'header'  = sprintf(Authorization: Basic %s\r\n, 
 base64_encode(myUsername:myPassword))
        )));
 $result = file_get_contents($url, 0, $ctx);
 $http_response = explode(' ', $http_response_header[0]);
 $response_code = $http_response[1];     === This is evaluating to '401'


 Thanks.

Are they using Basic authentication?

Does ...

https://myUsername:mypassw...@http://servername.com/script

work?

Is this a SOAP based web service?

Are they expecting the SOAPHeader to contain the authentication?




-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Help with sending credentials?

2010-10-15 Thread Tommy Pham
 -Original Message-
 From: Richard Quadling [mailto:rquadl...@gmail.com]
 Sent: Friday, October 15, 2010 1:47 AM
 To: Brian Dunning
 Cc: PHP-General List
 Subject: Re: [PHP] Help with sending credentials?
 
 On 14 October 2010 21:45, Brian Dunning br...@briandunning.com wrote:
  Gents -
 
  I'm trying to work with a major vendor's web service, but all my efforts are
 met with a 401 authentication error response. I can log in manually to this
 URL using these credentials through a browser, so I know the credentials are
 good. Unfortunately the support guys at the vendor don't see any problem
 with my code and have not been able to help.
 
  $url = https://servername.com/script;; $ctx =
  stream_context_create(array('https' = array(
 'timeout' = 10,
 'header'  = sprintf(Authorization: Basic %s\r\n,
  base64_encode(myUsername:myPassword))
 )));
  $result = file_get_contents($url, 0, $ctx); $http_response = explode('
  ', $http_response_header[0]); $response_code = $http_response[1];
  === This is evaluating to '401'
 
 
  Thanks.
 
 Are they using Basic authentication?
 
 Does ...
 
 https://myUsername:mypassw...@http://servername.com/script

Shouldn't that be https://myUsername:mypassw...@servername.com/script ?

 
 work?
 
 Is this a SOAP based web service?
 
 Are they expecting the SOAPHeader to contain the authentication?
 
 
 
 
 --
 Richard Quadling
 Twitter : EE : Zend
 @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
 

Regards,
Tommy


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with sending credentials?

2010-10-15 Thread Richard Quadling
On 15 October 2010 10:51, Tommy Pham tommy...@gmail.com wrote:
 -Original Message-
 From: Richard Quadling [mailto:rquadl...@gmail.com]
 Sent: Friday, October 15, 2010 1:47 AM
 To: Brian Dunning
 Cc: PHP-General List
 Subject: Re: [PHP] Help with sending credentials?

 On 14 October 2010 21:45, Brian Dunning br...@briandunning.com wrote:
  Gents -
 
  I'm trying to work with a major vendor's web service, but all my efforts 
  are
 met with a 401 authentication error response. I can log in manually to this
 URL using these credentials through a browser, so I know the credentials are
 good. Unfortunately the support guys at the vendor don't see any problem
 with my code and have not been able to help.
 
  $url = https://servername.com/script;; $ctx =
  stream_context_create(array('https' = array(
         'timeout' = 10,
         'header'  = sprintf(Authorization: Basic %s\r\n,
  base64_encode(myUsername:myPassword))
         )));
  $result = file_get_contents($url, 0, $ctx); $http_response = explode('
  ', $http_response_header[0]); $response_code = $http_response[1];
  === This is evaluating to '401'
 
 
  Thanks.

 Are they using Basic authentication?

 Does ...

 https://myUsername:mypassw...@http://servername.com/script

 Shouldn't that be https://myUsername:mypassw...@servername.com/script ?


 work?

 Is this a SOAP based web service?

 Are they expecting the SOAPHeader to contain the authentication?




 --
 Richard Quadling
 Twitter : EE : Zend
 @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY


 Regards,
 Tommy



Yeah. CNP error. Thanks.



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with sending credentials?

2010-10-14 Thread Adam Richardson
On Thu, Oct 14, 2010 at 4:45 PM, Brian Dunning br...@briandunning.comwrote:

 Gents -

 I'm trying to work with a major vendor's web service, but all my efforts
 are met with a 401 authentication error response. I can log in manually to
 this URL using these credentials through a browser, so I know the
 credentials are good. Unfortunately the support guys at the vendor don't see
 any problem with my code and have not been able to help.

 $url = https://servername.com/script;;
 $ctx = stream_context_create(array('https' = array(
'timeout' = 10,
'header'  = sprintf(Authorization: Basic %s\r\n,
 base64_encode(myUsername:myPassword))
)));
 $result = file_get_contents($url, 0, $ctx);
 $http_response = explode(' ', $http_response_header[0]);
 $response_code = $http_response[1]; === This is evaluating to '401'


 Thanks.
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Could the method (POST vs GET) or the content type be causing the issue
(hard to guess beyond this without knowing the service?)  See this simple
twitter function for examples of what I'm wondering about:
http://fabien.potencier.org/article/20/tweeting-from-php

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com