Note that there are some explanatory texts on larger screens.

plurals
  1. POphp curl - accessing url with http authentication (need help)
    primarykey
    data
    text
    <p>I have a problem in HTTP Authentication. I couldn't get the content of this url because it need http auth.</p> <p>Code:</p> <pre><code>&lt;?php $url = "http://www.abcdefg.com/12345/"; $username = 'username'; $password = 'password'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); $out = curl_exec($ch); print "error:" . curl_error($ch) . "&lt;br /&gt;"; print "output:" . $out . "&lt;br /&gt;&lt;br /&gt;"; curl_close($ch); ?&gt; </code></pre> <p>The Problem is: Instead of show the real content, it shows <strong>"302 Found, The document has moved here."</strong></p> <p>I've tried "http://username:password@www.abcdefg.com/12345/", doesn't work.</p> <p>When accessing this url(1), a popup window ask for username and password. but the popup window is from another url(2)(a sso authentication server). if pass the authentication. then it gets back to url(1) again. at this time, I can access the content of this url(1).</p> <p>I use <strong>firebug</strong> get the following message by accessing the url directly from browser:</p> <p><strong>Step 1</strong></p> <pre><code>URL: GET http://www.abcdefg.com/12345/ Status: 302 Found Protocol: http </code></pre> <p><strong>Step 2</strong></p> <pre><code>URL: GET https://www.ssoauth.com/obrareq.cgi?wh=xxx wu=xxx wo=xxx rh=http://www.abcdefg.com ru=/12345/ Status: 302 Redirect Protocol: https </code></pre> <p><strong>Step 3</strong></p> <pre><code>URL: GET http://www.abcdefg.com/obrar.cgi?cookie=xxxxxxxxxxxxxxx Status: 302 Found Protocol: http </code></pre> <p><strong>Step 4</strong></p> <pre><code>URL: GET http://www.abcdefg.com/12345/ Status: 200 OK Protocol: http </code></pre> <p>Then display the content…</p> <p><strong>Is this something to do with the cookie? How can I use php curl to read the content?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload