Jump to content

Recommended Posts

Hey Guys!

 

I have never used curl before but I have a little knowledge of it. Before I embark on this small project I have a quick question.

 

What I'm trying to do is this; use curl to login into my utility bill website and grab the new total of my bill then email me the total.

 

Is it possible using curl to grab info like that? Are there limitations as to certain sites curl can and cannot log into?

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/238323-a-little-curl-help/
Share on other sites

ok so i'm using this code:

 

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

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

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

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=mylogin&passoword=mypassword');

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

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

// CLOSE CURL
curl_close ($ch); 

?>

 

Now when I run this i just get a blank screen. How do I know if its logging in or not?

 

Also lets pretend it does login, how can I grab a value from the page it logged into?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/238323-a-little-curl-help/#findComment-1225154
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.