[Tutorial] Curl Login

This is a discussion on [Tutorial] Curl Login within the PHP forums, part of the Program Your Site category; ill be making a detailed regex tutorial...


Go Back   Scriptasy > Program Your Site > PHP
57 Online Register Projects Products Members List Calendar Today's Posts

Reply

 

LinkBack (19) Thread Tools Display Modes
  #21 (permalink)  
Old 01-21-2008, 10:22 AM
[Administrator]
 
Join Date: May 2007
Posts: 383
ill be making a detailed regex tutorial
Reply With Quote
  #22 (permalink)  
Old 03-29-2008, 07:27 PM
Junior Member
 
Join Date: Mar 2008
Posts: 2
Using Curl For Cj

Hi Chad!

i'd like to know if you can help me. I'm trying to login Commission Junction - A Global Leader in Affiliate Marketing, Online Advertising and Search Engine Marketing but it's so hard for me.

I've tried with this url and this other one:

https://members.cj.com/member/publisher/home.do that is the login page

The 2 both url have different POST data i have to send, these POST's data are:
Code:
uname=REMOVED&pw=REMOVED&submit.x=19&submit.y=5
and
Code:
uname=REMOVED&pw=REMOVED&nextpage=&go=Go
respectevely.

Well, I've seen the first POST data i wrote change temporaly. Where you see the "19" and the "5" sometimes change. But the second POST data i wrote to you is the same always, you just need to write your id and pass.

But anyway, i think the problem is for the COOKIE. When i intercept the data using ACHILLES i can see something like:

Code:
Cookie: cjlocale=en_US; __utma=xxxxxxxxx.xxxxxxxxxxx.xxxxxxxxxxxxx.xxxxxxxxxxxx.xxxxxxx.xxx; __utmz=xxxxxxxxx.xxxxxxxxxxx.xx.x.utmccn=(referral)|utmcsr=uk.cj.com|utmcct=/|utmcmd=referral; __utmb=xxxxxxxxx; CONTID=xxxxxxx; __utmc=xxxxxxxxxx
I've changed the cookie values because i'm not sure if i could share this data

This data changes temporaly too and sometimes include the JSESSIONID code

I've tested a lot of combination of these cookies with all the CURL's functions and i can't login. Always the browser shows me the CJ login form again.

As information, yesterday, i did the perfect code and it has worked fine for me, but that was just a newbie lucky because when i lost the session i wasn't be ables to login again. I've just changed the session and cookie values but it doesn't work.

Now, as i said, i've tested a lot of combination, even passing the utm... values i wrote above by adding the CURLOPT_COOKIE function and it doesnt't work neither.

Can u help me by saying to me what i have to write in your code to make it works perfectly for cj.com???

Thank you in advance.

Reinaldo.

P.D.: Sorry for my english, i know it isn't very good.
Reply With Quote
  #23 (permalink)  
Old 03-30-2008, 05:32 PM
[Administrator]
 
Join Date: May 2007
Posts: 383
well, if there is a session value that is changing and its a post field on the page what you will want to do is use, preg_match to grab the values on the page then add them to your post string. Hope this helps.
Reply With Quote
  #24 (permalink)  
Old 03-30-2008, 11:02 PM
Junior Member
 
Join Date: Mar 2008
Posts: 2
Quote:
Originally Posted by Chad View Post
well, if there is a session value that is changing and its a post field on the page what you will want to do is use, preg_match to grab the values on the page then add them to your post string. Hope this helps.
I'm not sure if i am understanding you. Well, you're right, i can use preg_match to grab the POST fields data, i don't know how to do that but that's not the problem.

The postfileds data i have to send in cj.com changes, but that's ok no problem and even the postfield data that i have to send to https://members.cj.com/member/login (that is basically the same login page) don't changes, this is better than the first one.

The problem is another one, i think it is about COOKIES. When i try your code and all the codes i've been testing i can see the following line in the cookie file grabbed by COOKIEJAR function:

members.cj.com FALSE / FALSE 0 JSESSIONID xxxxxxxxxxx

I think this line means that CURL is logging in satisfactorily because the this cookie shows me a JSESSIONID value. When the code fails a FALSE value is shown instead the JSESSIONID value.

Well, even showing the JSESSIONID value, CURL can't show me the page that i'm looking for inside the login form.

I think this problem is for COOKIE values, when i intercept the data, i can see my browser is sending to CJ server utma, utmc, utmz, utmb values and even sometimes the JSESSIONID as a cookie value.

Intercepting the data a lot of times, i can see this utmX values appear ramdomly. I mean, sometimes appears the utmb cookie and some other times not and it is the same for utmc, JSESSIONID and a cookie named cjuMember.

This values appears ramdomly even in the same session. I'm trying to pass this __utmX values by using the CURLOPT_COOKIE function but it still not working.

Do you know about the utmX cookie values and how can i pass this data to the session created by CURL???

Thank you in advance.

Reinaldo.
Reply With Quote
  #25 (permalink)  
Old 05-27-2008, 10:40 AM
Junior Member
 
Join Date: May 2008
Posts: 1
hmm I am also just starting to loggin with cookies/curl.

I had a little bit similar problem as you had above.
I needed to log in monsterboard.nl ( ssl hiring ).

I did the following thing and it worked.

step 1:

Quote:
$LOGINURL = " Login url "
";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
$result = curl_exec ($ch);
curl_close ($ch);

step 2 : cookie is written

$LOGINURL = " Now do live http headers and get the same post sent page";
$POSTFIELDS = '$post data';
$reffer = "Same url as LOGIN url";

$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_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
$result = curl_exec ($ch);
curl_close ($ch);



This should do the job.
Reply With Quote
  #26 (permalink)  
Old 09-02-2008, 12:17 AM
Junior Member
 
Join Date: Sep 2008
Posts: 1
Sorry resurrect the topic,
More here the page is blank
when I try, Reason?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://scriptasy.com/php_11/tutorial-curl-login_44.html

Posted By For Type Date
Can a website block the use of file_get_contents ? - PHWinfo This thread Refback 08-22-2008 01:13 AM
Can a website block the use of file_get_contents ? - comp.lang.php | Google Groups This thread Refback 04-26-2008 11:12 AM
Can a website block the use of file_get_contents ? - comp.lang.php | Google Groupes This thread Refback 04-23-2008 04:43 AM
Live website statistieken - Ulco.nl This thread Pingback 03-31-2008 11:37 AM
Can a website block the use of file_get_contents ? - comp.lang.php | Google Groups This thread Refback 03-31-2008 08:03 AM
Can a website block the use of file_get_contents ? - comp.lang.php | Google Groups This thread Refback 03-29-2008 03:21 AM
Can a website block the use of file_get_contents ? - Object Mix This thread Refback 03-29-2008 03:10 AM
Can a website block the use of file_get_contents ? - Usenet Forums This thread Refback 03-28-2008 10:45 AM
Web Link This thread Refback 09-05-2007 07:15 PM
amob005's bookmarks tagged with "php_curl_video_tutorial" on del.icio.us This thread Refback 08-12-2007 12:41 AM
digg / blizzedout / news / dugg This thread Refback 06-17-2007 02:14 AM
digg / beasttoast / news / submitted This thread Refback 06-02-2007 02:02 PM
YouTube - Curl Login Tutorial This thread Refback 05-31-2007 04:37 PM
Digg / Programming / Upcoming This thread Refback 05-31-2007 01:36 PM
Digg / Programming / Upcoming This thread Refback 05-31-2007 09:16 AM
Digg / News / Upcoming This thread Refback 05-30-2007 10:08 PM
Digg / News / Upcoming This thread Refback 05-30-2007 10:05 PM
Digg / News / Upcoming This thread Refback 05-30-2007 10:00 PM
Digg - [Tutorial] PHP Curl Login This thread Refback 05-30-2007 10:00 PM


All times are GMT -8. The time now is 05:55 PM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
scriptasy girl by HitmanN

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
W33