'curl lib in php needs html button click

I am trying to open a SAML xml endpoint with the following PHP code:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$URL);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($ch, CURLOPT_USERPWD, $user":" . $pass" ));
    $result=curl_exec ($ch);
    $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);   //get status code
    curl_close ($ch);

    print_r($result);
    print_r($status_code);

but it's returning:<html><head><meta http-equiv="cache-control" content="no-cache" /><meta http-equiv="pragma" content="no-cache" /></head><body onload="javascript:var url=window.location.hash;if(url&&(0!==url.length)){document.cookie=&quot;oucqqvqvwacozrdvoredcobudyoycwurfuecsud_anchor=&quot;+escape(url)+&quot;; path=/&quot;}document.forms[0].submit()"><noscript><p><strong>Note:</strong> Since your browser does notsupport JavaScript, you must press the Continuebutton once to</p></noscript><form method="POST" action="https://portal.org/oa/samlv20"><input type="hidden" name="SAMLRequest" value="NhbWxwOkF1dGhuUmVxdWVzdCBJRD0iUzAwNTA1NmFjLTkxZDUtMWVkYy1iNGQ4LThjNjQxZjRlYzI0ZCIgVmVyc2lvbj0iMi4wIiBJc3N1ZUluc3RhbnQ9IjIwMjItMDUtMTNUMTM6NTU6NDZaIiBEZXN0aW5hdGlvbj0iaHR0cHM6Ly9pZ2FtLmVjYi5ldXJvcGEuZXUvb2FtZmVkL2lkcC9zYW1sdjIwIiBGb3JjZUF1dGhuPSJmYWxzZSIgSXNQYXNzaXZlPSJmYWxzZSIgeG1sbnM6c2FtbHA9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpwcm90b2NvbCI&#x2b;PHNhbWw6SXNzdWVyIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24iPlBXM19TQU1MMjwvc2FtbDpJc3N1ZXI&#x2b;PGRzOlNpZ25hdHVyZSB4bWxuczpkcz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnIyI&#x2b;PGRzOlNpZ25lZEluZm8&#x2b;PGRzOkNhbm9uaWNhbGl6YXRpb25NZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzEwL3htbC1leGMtYzE0biMiLz48ZHM6U2lnbmF0dXJlTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8wNC94bWxkc2lnLW1vcmUjcnNhLXNoYTI1NiIvPjxkczpSZWZlcmVuY2UgVVJJPSIjUzAwNTA1NmFjLTkxZDUtMWVkYy1iLThjNjQxZjRlYzI0ZCI&#x2b;PGRzOlRyYW5zZm9ybXM&#x2b;PGRzOlRyYW5zZm9ybSBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyNlbnZlbG9wZWQtc2lnbmF0dXJlIi8&#x2b;&#x2b;&#x2b;&#x2b;PC9kczpTaWduYXR1cmU&#x2b;PHNhbWxwOk5hbWVJRFBvbGljeSBGb3JvYXNpczpuYW1lczp0YzpTQU1MOjEuMTpuYW1laWQtZm9ybWF0OnVuc3BlY2lmaWVkIiBBbGxvd0NWF0ZT0idHJ1ZSIvPjwvc2FtbHA6QXV0aG5SZXF1ZXN0Pg&#x3d;&#x3d;"><input type="hidden" name="RelayState" value="oucqqvqvwacozrdvoredcobudyoycwurfuecsud"><noscript><input type="submit" value="Continue"></noscript></form></body></html>200null

where 200 is the http response. I am willing to try anything and also provide more information, but I don't have any control over the endpoint just to use it.

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source