Page 1 of 1

I need help with curl...

Posted: Fri Nov 16, 2007 7:05 pm
by Snix
Hi there,

please if somebody can help me with a simple curl example, all i need is that the script to do the following:

enter on a website - http://example.com/index.php
get the cookies from that page
save cookie to cookie.txt
after that using the cookies enter on the http://exemple.com/newpage.php
clear cookie from file.


I will appreciate your help.

Many Thanks

Posted: Sat Nov 17, 2007 6:27 am
by feyd
We won't do your work for you. What have you tried so far?

Posted: Sat Nov 17, 2007 9:54 am
by Snix
feyd wrote:We won't do your work for you. What have you tried so far?
Yes I have tried.

Code: Select all

<?php

$cookie_file = 'cookies.txt';
$url_1 = 'http://example.com/index.php';
$url_2 = 'http://exemple.com/newpage.php';

$ch = curl_init($url_1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);


curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $url_2);

curl_exec($ch);
curl_close($ch);


file_put_contents($cookie_file, null);

?>
On my home computer I have apache installed and every time when I open my browser I would like this script to open automatically the ebay page and log me in. I tried to modify this script for using ebay, but i receive an error that my browser is rejecting cookies.


Thanks
Snix

Posted: Sat Nov 17, 2007 9:56 am
by feyd
That appears to be fine. Does it function as you expect?

Posted: Sat Nov 17, 2007 9:58 am
by Snix
feyd wrote:That appears to be fine. Does it function as you expect?

Is not working, because the ebay use ssl, and i really don't know how to make it... sorry, newbie here.

I will appreciate your help.

Posted: Sat Nov 17, 2007 10:00 am
by John Cartwright
Dig through the user comments on http://php.net/curl_setopt, there are quite a few examples of sending to SSL enabled sites.

Posted: Sat Nov 17, 2007 10:16 am
by Snix
Jcart wrote:Dig through the user comments on http://php.net/curl_setopt, there are quite a few examples of sending to SSL enabled sites.
I've just made it... many thanks.