Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't get my curl login script to work?

Status
Not open for further replies.

pushyr

Programmer
Joined
Jul 2, 2007
Messages
159
Location
GB
i've been following tutorials by the letter, but can't get my curl login script to work

do you see something that i might be doing incorrect?

Code:
$loginPage = '[URL unfurl="true"]http://www.test_page_login.com';[/URL]
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; 
$referrer = '[URL unfurl="true"]http://www.test.com';[/URL]
$cookieFile = 'cookie.txt';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ''.$loginPage.'');
curl_setopt($ch, CURLOPT_USERAGENT, $useragent); 
curl_setopt($ch, CURLOPT_REFERER, ''.$referrer.'');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'emailx=test@email.com&password=myPass');
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$content = curl_exec ($ch);

curl_close ($ch); 

echo '<p>'.$content.'</p>';
 
you probably need a session cookie from the referring site.

given the two url are in different domains one assumes that the session cookie must be passed in the url as part of the query string rather than as an ordinary cookie.

we may be able to assist further if you provide the url's you are using.
 
..., but can't get my curl login script to work

This is not particularly helpful. What is happening? What should be happening instead? Do you get any errors or warnings? What status functions do you check to see what the errors or warnings are? What is the output of $content?

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top