Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5172 > unrolled thread

example CURL to form in Https

Started byVivian <viviansank@gmail.com>
First post2012-03-16 19:44 -0700
Last post2012-03-18 14:37 +0100
Articles 6 — 3 participants

Back to article view | Back to comp.lang.php


Contents

  example CURL to form in Https Vivian <viviansank@gmail.com> - 2012-03-16 19:44 -0700
    Re: example CURL to form in Https Jerry Stuckle <jstucklex@attglobal.net> - 2012-03-17 05:23 -0400
      Re: example CURL to form in Https Vivian <viviansank@gmail.com> - 2012-03-17 06:38 -0700
        Re: example CURL to form in Https Jerry Stuckle <jstucklex@attglobal.net> - 2012-03-17 10:55 -0400
          Re: example CURL to form in Https Vivian <viviansank@gmail.com> - 2012-03-18 05:49 -0700
            Re: example CURL to form in Https "J.O. Aho" <user@example.net> - 2012-03-18 14:37 +0100

#5172 — example CURL to form in Https

FromVivian <viviansank@gmail.com>
Date2012-03-16 19:44 -0700
Subjectexample CURL to form in Https
Message-ID<ee1af577-8952-410a-965e-7d7af6a9ee3c@2g2000yqk.googlegroups.com>
friends I am testing and researching various examples of work and
nothing
example we will get to https page
as script to get email and password and click access automatically?

[toc] | [next] | [standalone]


#5173

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-03-17 05:23 -0400
Message-ID<jk1l6s$u7n$1@dont-email.me>
In reply to#5172
On 3/16/2012 10:44 PM, Vivian wrote:
> friends I am testing and researching various examples of work and
> nothing
> example we will get to https page
> as script to get email and password and click access automatically?

What have you looked for?  Have you tried cURL?

Note that any script you do find will be heavily dependent on the page 
you're accessing.  Normally scripts similar to what (I think) you're 
requesting have to be done from scratch.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#5174

FromVivian <viviansank@gmail.com>
Date2012-03-17 06:38 -0700
Message-ID<2e735f94-dbcc-4ff1-9c49-bb11064ce5ad@w5g2000yqi.googlegroups.com>
In reply to#5173
I'm trying to feed with CURL code live_HTTP_headers (firefox plug in)
but it shows blank page because it's https.

I want a code to enter user and password and click signup now.

Example page:
https://signup.netflix.com/Login

i am no idea to work, help
Vivian





On 17 Mar, 06:23, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 3/16/2012 10:44 PM, Vivian wrote:
>
> > friends I am testing and researching various examples of work and
> > nothing
> > example we will get to https page
> > as script to get email and password and click access automatically?
>
> What have you looked for?  Have you tried cURL?
>
> Note that any script you do find will be heavily dependent on the page
> you're accessing.  Normally scripts similar to what (I think) you're
> requesting have to be done from scratch.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

[toc] | [prev] | [next] | [standalone]


#5175

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-03-17 10:55 -0400
Message-ID<jk28lr$stt$1@dont-email.me>
In reply to#5174
On 3/17/2012 9:38 AM, Vivian wrote:
> On 17 Mar, 06:23, Jerry Stuckle<jstuck...@attglobal.net>  wrote:
>> On 3/16/2012 10:44 PM, Vivian wrote:
>>
>>> friends I am testing and researching various examples of work and
>>> nothing
>>> example we will get to https page
>>> as script to get email and password and click access automatically?
>>
>> What have you looked for?  Have you tried cURL?
>>
>> Note that any script you do find will be heavily dependent on the page
>> you're accessing.  Normally scripts similar to what (I think) you're
>> requesting have to be done from scratch.
>>
 > I'm trying to feed with CURL code live_HTTP_headers (firefox plug in)
 > but it shows blank page because it's https.
 >
 > I want a code to enter user and password and click signup now.
 >
 > Example page:
 > https://signup.netflix.com/Login
 >
 > i am no idea to work, help
 > Vivian
 >
 >
 >
 >
 >

<Top posting corrected>

The firefox plugin won't show anything because PHP isn't running under 
the browser.  cURL will run separate from the browser and not interact 
with your browser.

If you're loading a web page with PHP code, that web page will be 
running on a server somewhere, and that server would be connecting to 
the site.  If you're running PHP as a CLI (Command Line Interface), then 
your computer will be connecting, but you won't see anything in a browser.

What you will need to do is use cURL to request the page, parse the 
response, then send the necessary information back to the server.  On 
some sites it's pretty easy, but others make it very difficult or almost 
impossible by requiring things like javascript generated values, CAPTCHA 
codes, etc.

cURL works fine with https.  The most common problem is not setting cURL 
up to accept the server's certificate (which provides an error message). 
 
http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/ 
has a good description on how to set up cURL to accept the certificate.

Other than setting the proper options in cURL, there really isn't any 
difference in accessing URIs with http or https protocols.

P.S. Please don't top post.  Thanks.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#5181

FromVivian <viviansank@gmail.com>
Date2012-03-18 05:49 -0700
Message-ID<3e5a290d-a28d-434a-a3d4-2cb7c2db087d@i5g2000yqo.googlegroups.com>
In reply to#5175
On 17 Mar, 11:55, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 3/17/2012 9:38 AM, Vivian wrote:> On 17 Mar, 06:23, Jerry Stuckle<jstuck...@attglobal.net>  wrote:
> >> On 3/16/2012 10:44 PM, Vivian wrote:
>
> >>> friends I am testing and researching various examples of work and
> >>> nothing
> >>> example we will get to https page
> >>> as script to get email and password and click access automatically?
>
> >> What have you looked for?  Have you tried cURL?
>
> >> Note that any script you do find will be heavily dependent on the page
> >> you're accessing.  Normally scripts similar to what (I think) you're
> >> requesting have to be done from scratch.
>
>  > I'm trying to feed with CURL code live_HTTP_headers (firefox plug in)
>  > but it shows blank page because it's https.
>  >
>  > I want a code to enter user and password and click signup now.
>  >
>  > Example page:
>  >https://signup.netflix.com/Login
>  >
>  > i am no idea to work, help
>  > Vivian
>  >
>  >
>  >
>  >
>  >
>
> <Top posting corrected>
>
> The firefox plugin won't show anything because PHP isn't running under
> the browser.  cURL will run separate from the browser and not interact
> with your browser.
>
> If you're loading a web page with PHP code, that web page will be
> running on a server somewhere, and that server would be connecting to
> the site.  If you're running PHP as a CLI (Command Line Interface), then
> your computer will be connecting, but you won't see anything in a browser.
>
> What you will need to do is use cURL to request the page, parse the
> response, then send the necessary information back to the server.  On
> some sites it's pretty easy, but others make it very difficult or almost
> impossible by requiring things like javascript generated values, CAPTCHA
> codes, etc.
>
> cURL works fine with https.  The most common problem is not setting cURL
> up to accept the server's certificate (which provides an error message).
>
> http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https...
> has a good description on how to set up cURL to accept the certificate.
>
> Other than setting the proper options in cURL, there really isn't any
> difference in accessing URIs with http or https protocols.
>
> P.S. Please don't top post.  Thanks.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

where is wrong ? show the blank page only...

<?php
// INIT CURL
$ch = curl_init();

// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'https://www.coelce.com.br/
default.aspx');

// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS,
'ctl00$ctl00$ctl00$ContentPlaceHolderDefault$ContentPlaceHolderDefault
$Login_3$LoginView1$CadastroLogin1$UserName=email123@hotmail.com&ctl00$ctl00$ctl00$ContentPlaceHolderDefault
$ContentPlaceHolderDefault
$Login_3$LoginView1$CadastroLogin1$Password=senha123');

// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);


// EXECUTE 2nd REQUEST (FILE DOWNLOAD)
$content = curl_exec ($ch);

// CLOSE CURL
curl_close ($ch);

?>

[toc] | [prev] | [next] | [standalone]


#5182

From"J.O. Aho" <user@example.net>
Date2012-03-18 14:37 +0100
Message-ID<9sm6oiFch6U1@mid.individual.net>
In reply to#5181
Vivian wrote:

<Cut away non needed text as mail footers and things not replayed to>

> where is wrong ? show the blank page only...
 >
> // CLOSE CURL
> curl_close ($ch);
>
> ?>

If you don't make any output, then you will not get anything else than a blank 
page.


> // EXECUTE 1st REQUEST (FORM LOGIN)
> $store = curl_exec ($ch);
>
>
> // EXECUTE 2nd REQUEST (FILE DOWNLOAD)
> $content = curl_exec ($ch);

Are you sure making the same request (login) will give you the content?
Are you even sure your login was successful? It may be good to use 
curl_error() to see if something went wrong (if login fails, fetching file 
will also fail and no point in trying to do that if the login failed).


-- 

   //Aho

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web