Forum Moderators: coopster
I am using php cURL session to fetch a page from third party site. I want to add a domain name to the action value of all the forms present in the page
e.g
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['HTTP_REFERER']);
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/');
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/');
$result = curl_exec ($ch);
curl_close ($ch);
$contents = preg_match('/form.+?action="([^"]*)/s', $result, $mat);
echo "<pre>";
print_r($matches);
$matchesgives me the exact page name, I want to add http://domain.com/$matches[1] before displaying it on the browser. **** in fact my main problem is that I have to forward some information to a thirdparty site that store a critical variable values in its cookie. If I simply display their page in a window hosted on my server then the problem of action pages raise because they refer to the pages with only page name and therefore the form tries to search for that page on my server... I tried to use a technique by collecting all the variables and then using an iframe to open the thirdparty page with querystring so that all the control was shift to the site itself but in that case I am not able to by pass cookies check I have no idea if we can create a cookie by simply posting a querystring in iframe so I thought to stick back with my previous method and add domain name in form action page values instead. Any help is highly appreciated. [1][edited by: eelixduppy at 1:38 pm (utc) on May 12, 2007]
[edit reason] delinked [/edit]
the first curl session opens in a window that resides on my server. i create the cookie file that is also stored on my server, this cookie has a URL that thirdparty site need in the final step of the process.
as the from the second step all the control is shift to the third party site itself, it fails to carry cookie from my server and in the final step it gives error because third party site cannot find the URL in the cookie on its own server...
does anyone know how to send cookie from my first curl session to the third party site so that it can read the URL in the final step?
1 - a browser window opens on my server and fetch a page from third party site, in this step it generates a cookie which is stored on my server of course, this cookie has a URL.
2 - visitor can select a value and submit then the control is totally shifted to the third party site
3 - after three similar forms finally the site uses the URL from its cookie to send output
now my problem is that i have only the first step on my server and visitor is sent to the third party site from second step, i did http sniffing and have tracked that when the visitor goes to the second step the cookie value is left on my server and the third party site doesn't have that URL in it generated in the first step
Can anybody guide me please how can I send the cookie generated from the first step which is stored on my server to the third party site in the step 2 so that that URL can be added to third party site cookie?
is there any header technique etc we can use?