Jump to content


Photo

cURL problems


  • Please log in to reply
No replies to this topic

#1 jjfletch

jjfletch
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 12 October 2006 - 06:38 AM

Basically, there is a secured site, which I can log into and then add data via a form once I'm logged in.  I can pass the login information in the URL, and I can get it to work if, for example, I type the address into my browser bar, like so:

   
https://my.example.com/authentication.php?user=Username&pass=PW&destination=https://someurl.example.com/Something
This will bring me to the page I want to post form data to.  Which is great, except that if I use this url in my code, it doesn't work.  It just brings me back to the initial login page.  I should also say that if I use:

    header("Location: https://my.example.com/authentication.php?user=Username&pass=PW&destination=https://someurl.example.com/Something");
I will be brought to the form that I want to post data to.  The problem is that I don't want to actually redirect to the page, I just want to get to the form that I need to post information to.

If I attempt to call this URL in my code, it doesn't work.  There are multiple redirects that occur if I type it in the address bar, and I've used FOLLOWLOCATION, 1, but that doesn't seem to help. 

The latest iteration of code attempts to request the page that sets the cookies, and then make subsequent requests that include the cookies, but it still winds up kicking me back to the first page.

$cookie_jar = tempnam('/tmp','cookie');

$c = curl_init('https://my.example.com/authentication.php?user=Username&pass=PW');
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);
$page = curl_exec($c);
curl_close($c);


$c = curl_init('https://someurl.example.com/Something');
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, 'field=value');
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);
$page = curl_exec($c);
curl_close($c);

Can anyone help?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users