Activity Stream
48,167 MEMBERS
61189 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1.     
    #1
    Member
    Website's:
    oxioServices.com teamOxio.com blackOxio.com

    Smile Problem using CURL

    Hiya all,

    I'm trying to use cURL to submit a form on a site (http://ipower.com) and then save the cookie given by the site.
    The exact url being: https://secure.ipower.com/secure/login.bml?err=

    Can anyone guide me how can i do that ?
    black0xio Reviewed by black0xio on . Problem using CURL Hiya all, I'm trying to use cURL to submit a form on a site (http://ipower.com) and then save the cookie given by the site. The exact url being: https://secure.ipower.com/secure/login.bml?err= Can anyone guide me how can i do that ? Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    use this to save cookies to a local file.
    PHP Code: 
    curl_setopt($chCURLOPT_COOKIEJAR$path_to_save_cookie); 
    Coding Horror Fan
    I don't read PM's frequently .

  4.     
    #3
    Member
    Website's:
    wscripts.net damnlolscript.com lulzjet.com
    try this:
    function get_web_page( $url )
    {
    $options = array(
    CURLOPT_RETURNTRANSFER => true, // return web page
    CURLOPT_HEADER => true, // don't return headers
    CURLOPT_FOLLOWLOCATION => true, // follow redirects
    CURLOPT_ENCODING => "", // handle all encodings
    CURLOPT_USERAGENT => "spider", // who am i
    CURLOPT_AUTOREFERER => true, // set referer on redirect
    CURLOPT_CONNECTTIMEOUT => 60, // timeout on connect
    CURLOPT_TIMEOUT => 30, // timeout on response
    CURLOPT_MAXREDIRS => 5, // stop after 10 redirects
    CURLOPT_COOKIEFILE => dirname(__FILE__) . "/cookies.txt",
    );

    $ch = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err = curl_errno( $ch );
    $errmsg = curl_error( $ch );
    $header = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno'] = $err;
    $header['errmsg'] = $errmsg;
    $header['content'] = $content;

    return $header;
    }

  5.     
    #4
    Member
    Website's:
    oxioServices.com teamOxio.com blackOxio.com
    @desiboy: Already tried that but no success.

  6.     
    #5
    Member
    Website's:
    oxioServices.com teamOxio.com blackOxio.com
    guys whenever i try submitting the form on ipower.com the curl fails to connect , i mean it doesnt connects to ipower.com but instead connects to my localhost.

    Here are the headers i get :

    Code: 
    http://127.0.0.1/curl2.php
    
    GET /curl2.php HTTP/1.1
    Host: 127.0.0.1
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    
    HTTP/1.1 200 OK
    Date: Sun, 01 Aug 2010 11:10:25 GMT
    Server: Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0
    X-Powered-By: PHP/5.3.0
    Content-Length: 0
    Keep-Alive: timeout=5, max=98
    Connection: Keep-Alive
    Content-Type: text/html
    ----------------------------------------------------------
    http://127.0.0.1/favicon.ico
    
    GET /favicon.ico HTTP/1.1
    Host: 127.0.0.1
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    
    HTTP/1.1 404 Not Found
    Date: Sun, 01 Aug 2010 11:10:28 GMT
    Server: Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0
    Vary: accept-language,accept-charset
    Accept-Ranges: bytes
    Keep-Alive: timeout=5, max=97
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: text/html; charset=iso-8859-1
    Content-Language: en

  7.     
    #6
    Member




    PHP Code: 
    <?
    $ch 
    curl_init();
    curl_setopt($chCURLOPT_URL"https://secure.ipower.com/secure/login.bml?err=");
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    curl_setopt($chCURLOPT_POSTtrue);
    $things = array(
     
    'credential_0' => 'desi',
     
    'credential_1' => 'mypass'
    );
    curl_setopt($chCURLOPT_POSTFIELDS$things);
    curl_setopt($chCURLOPT_COOKIEJAR'cookies.txt');
    curl_setopt($chCURLOPT_COOKIEFILE'cookies.txt');

    $output curl_exec($ch);
    curl_close($ch);
    ?>
    I was able to store the cookies to a text file...make sure cookies.txt is writable..
    Coding Horror Fan
    I don't read PM's frequently .

  8.     
    #7
    Member
    Website's:
    oxioServices.com teamOxio.com blackOxio.com
    Thank you all at last i got it working.
    Thanks to t3odor for his function. the full code is as follows in case any1 needs it
    Had to edit some parts though but you got my mind working
    Code: 
    
    <?php
    function get_web_page( $url )
    {
    $options = array(
    CURLOPT_RETURNTRANSFER => true, // return web page
    CURLOPT_HEADER => true, // don't return headers
    CURLOPT_ENCODING => "", // handle all encodings
    CURLOPT_USERAGENT => "spider", // who am i
    CURLOPT_AUTOREFERER => true, // set referer on redirect
    CURLOPT_CONNECTTIMEOUT => 60, // timeout on connect
    CURLOPT_TIMEOUT => 30, // timeout on response
    CURLOPT_MAXREDIRS => 5, // stop after 10 redirects
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_COOKIEJAR => dirname(__FILE__) . "\cookie1.txt",
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => "MY POST DATA HERE FOR LOGIN :)"
    );
    
    $ch = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err = curl_errno( $ch );
    $errmsg = curl_error( $ch );
    $header = curl_getinfo( $ch );
    curl_close( $ch );
    
    $header['errno'] = $err;
    $header['errmsg'] = $errmsg;
    $header['content'] = $content;
    
    return $header;
    }  //end of fn
    
    
    
    
    
    function mailbox( $url )
    {
    $options = array(
    CURLOPT_RETURNTRANSFER => true, // return web page
    CURLOPT_HEADER => true, // don't return headers
    CURLOPT_ENCODING => "", // handle all encodings
    CURLOPT_USERAGENT => "spider", // who am i
    CURLOPT_AUTOREFERER => true, // set referer on redirect
    CURLOPT_CONNECTTIMEOUT => 60, // timeout on connect
    CURLOPT_TIMEOUT => 30, // timeout on response
    CURLOPT_MAXREDIRS => 5, // stop after 10 redirects
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_COOKIEFILE => dirname(__FILE__) . "\cookie1.txt",
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => "POST DATA FOR CREATING NEW MAIL BOX HERE"
    );
    
    $ch = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err = curl_errno( $ch );
    $errmsg = curl_error( $ch );
    $header = curl_getinfo( $ch );
    curl_close( $ch );
    
    $header['errno'] = $err;
    $header['errmsg'] = $errmsg;
    $header['content'] = $content;
    
    return $header;
    }  //end of fn
    
    get_web_page("https://secure.ipower.com/secureLogin");
    mailbox("http://members.ipower.com/webControl/emailpack/mailcentral.bml");
    ?>
    Thanks again

  9.     
    #8
    Member
    Website's:
    oxioServices.com teamOxio.com blackOxio.com
    @desiboy: I saw your code a bit late otherwise it would have saved me some time

  10.     
    #9
    Member
    When using cookies/sessions make sure the file has write acces

  11.     
    #10
    Member
    Website's:
    mirrormaker.org
    When using cookies/sessions make sure the file has write acces
    Wasn't the problem because he was trying to connect via https?
    Busy with real life - unlikely to see new PM's

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Help] PHP Curl Lumfile.com Problem
    By heppinnz in forum Web Development Area
    Replies: 4
    Last Post: 23rd Jun 2012, 02:21 PM
  2. PHP CURL Problem with Pixhost.org
    By heppinnz in forum Web Development Area
    Replies: 6
    Last Post: 20th Jun 2012, 05:10 PM
  3. [Help] PHP Curl Uploader to RapidShare Problem
    By heppinnz in forum Web Development Area
    Replies: 2
    Last Post: 29th Nov 2011, 06:28 AM
  4. curl problem
    By cyberz in forum Technical Help Desk Support
    Replies: 5
    Last Post: 6th Aug 2010, 09:05 PM
  5. cURL or PHP Problem.
    By deelow66 in forum Technical and Security Tutorials
    Replies: 4
    Last Post: 2nd May 2010, 01:57 AM

Tags for this Thread

BE SOCIAL