1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ping.fm auto signup script

Discussion in 'PHP & Perl' started by dithmo, Jul 14, 2011.

  1. dithmo

    dithmo Newbie

    Joined:
    Jun 12, 2008
    Messages:
    16
    Likes Received:
    25
    hi folks, im trying to write a ping.fm autosignup script using php and curl. im new to the whole language and iv hit a problem and cant see where im going wrong. the script runs but the curl function doesn't return anything, I think it might have something to do with the email variable that im posting to the sign up page but im not sure. the code im using is:
    PHP:
    function fn_pingfm ($fname,$usern,$password,$email) {

        
    $useragent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
        
    $continue true;
        
        
    $postString1 = array("email" => "",
                            
    "addy" => $email,
                            
    "password" => $password,
                            
    "vpassword" => $password,
                            
    "nl" => "N" );
        
    $ch curl_init();//most places use cookies, so it?s necessary to load the home page first
        
    curl_setopt($chCURLOPT_URL,'ping.fm');
        
    curl_setopt($chCURLOPT_USERAGENT$useragent);//set our user agent to emulate firefox 
        
    curl_setopt($chCURLOPT_COOKIEJAR"cookie1.txt");//set our location to store cookies
        
    curl_setopt($chCURLOPT_COOKIEFILE"cookie1.txt");
        
    curl_setopt($chCURLOPT_RETURNTRANSFER ,1);//says we want the data that results from the request
        
    curl_setopt($chCURLOPT_FOLLOWLOCATION ,0);//Do not follow redirects
        
    curl_setopt($chCURLOPT_POST0);//we?re not doing a post request, yet
        
    curl_setopt($chCURLOPT_HEADER0);//don?t return the header
        
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);//not really needed for this one, but just keep it. trust me.
        
    curl_setopt($chCURLOPT_AUTOREFERER0);
        
    $data=curl_exec($ch);//execute the command
        
        ///////////////////////This part is where we actually submit the form data, to sign-up!////////////////////
        
        
    echo $data.'<hr>';
        
        
    curl_setopt($chCURLOPT_URL,"ping.fm/signup.php");//set this URL to wherever the form submits to
        
    curl_setopt($chCURLOPT_USERAGENT$useragent);//set our user agent to emulate firefox 
        
    curl_setopt($chCURLOPT_COOKIEJAR"cookie1.txt");//set our location to store cookies
        
    curl_setopt($chCURLOPT_COOKIEFILE"cookie1.txt");
        
    curl_setopt($chCURLOPT_RETURNTRANSFER ,1);//says we want the data that results from the request
        
    curl_setopt($chCURLOPT_FOLLOWLOCATION ,0);//Do not follow redirects
        
    curl_setopt($chCURLOPT_POST,1);//yes we want to post
        
    curl_setopt($chCURLOPT_HEADER0);//don?t return the header
        
    curl_setopt($chCURLOPT_POSTFIELDS,$postString1);//tell it where to find our sign up string
        
    $data=curl_exec($ch);
        
        echo 
    $data;
        
        
    curl_close($ch);//close the session
            
    }

    ?>
    now the first echo works fine and echos the front page of ping.fm and also creates a cookie in the cookie1.txt file, however the second curl returns nothing. I tried to urlencode the email address and the curl returned a ping.fm page with an "invalid email address" on it so the curl is connecting it just wont return anything. could it be something to do with the at character? that's just a guess from something I saw while searching for a solution but im not sure. any help would be appreciated guys, thanks :)
     
  2. wowhaxor

    wowhaxor Executive VIP Premium Member

    Joined:
    Apr 28, 2007
    Messages:
    2,021
    Likes Received:
    3,353
    Location:
    ?¿?
    Home Page:
    Haven't looked at your code yet but I just started something for automating sign up and verifying accounts for both Ping.fm and Onlywire.com so I'll keep an eye on this thread and chime in when I get further along
     
  3. xpwizard

    xpwizard Junior Member

    Joined:
    Nov 6, 2010
    Messages:
    198
    Likes Received:
    122
    Here you go, changed it around to work and made some notes for you.


    PHP:
    <?php 

        
    function fn_pingfm ($fname,$usern,$password,$email) { 

            
    $useragent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"

            
    // urlencode fields
            
    $fields = array();
            
    $fields ['email'] = '';
            
    $fields ['addy'] = $email;
            
    $fields ['password'] = $password;
            
    $fields ['vpassword'] = $password;
            
    $post '';
            foreach(
    $fields as $key=>$val) {
                
    $post .= $key '=' .urlencode($val).'&';
            }
            
    $post substr($post0, -1);    

            
    // send first request to ping.fm to get cookies
            
    $ch curl_init(); 
            
    curl_setopt($chCURLOPT_URL,'http://ping.fm'); 
            
    curl_setopt($chCURLOPT_USERAGENT$useragent);  
            
    curl_setopt($chCURLOPT_COOKIEJAR"cookie1.txt"); 
            
    curl_setopt($chCURLOPT_RETURNTRANSFER 1); 
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION 1); 
            
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);  
            
    $data=curl_exec($ch);

            
    // echo the homepage
            
    echo $data.'<hr>'

            
    // post to signup form
            
    curl_setopt($chCURLOPT_URL,"http://ping.fm/signup.php"); 
            
    curl_setopt($chCURLOPT_USERAGENT$useragent);  
            
    curl_setopt($chCURLOPT_COOKIEJAR"cookie1.txt"); 
            
    curl_setopt($chCURLOPT_COOKIEFILE"cookie1.txt"); 
            
    curl_setopt($chCURLOPT_RETURNTRANSFER 1); 
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION 1);    // when you submit a form you need to follow the redirect 
            
    curl_setopt($chCURLOPT_POST1);
            
    curl_setopt($chCURLOPT_POSTFIELDS$post);
            
    curl_setopt($chCURLOPT_AUTOREFERER1); // when dealing with multiple pages, have curl fill out referrer 
            
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
            
    $data=curl_exec($ch);

            
    curl_close($ch);

            
    // echo page after signup
            
    echo $data;    

        }

        echo 
    fn_pingfm ('Bob''bobbybobbobster123''grn024y45''bobbybob123@gmail.com'); 

    ?>
     
    Last edited: Jul 15, 2011
  4. dithmo

    dithmo Newbie

    Joined:
    Jun 12, 2008
    Messages:
    16
    Likes Received:
    25
    Thanks very much xpwizard, just got that now so ill go and play with it and see if i understand where i went wrong :)
     
  5. Royalserviceteam

    Royalserviceteam Power Member

    Joined:
    Apr 2, 2011
    Messages:
    714
    Likes Received:
    230
    Occupation:
    fulltime IM
    Oh nice...... was waiting for something like this.