ping.fm auto signup script

dithmo

Newbie
Joined
Jun 12, 2008
Messages
16
Reaction score
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($ch, CURLOPT_URL,'ping.fm');
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);//set our user agent to emulate firefox 
    curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie1.txt");//set our location to store cookies
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie1.txt");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);//says we want the data that results from the request
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,0);//Do not follow redirects
    curl_setopt($ch, CURLOPT_POST, 0);//we?re not doing a post request, yet
    curl_setopt($ch, CURLOPT_HEADER, 0);//don?t return the header
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);//not really needed for this one, but just keep it. trust me.
    curl_setopt($ch, CURLOPT_AUTOREFERER, 0);
    $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($ch, CURLOPT_URL,"ping.fm/signup.php");//set this URL to wherever the form submits to
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);//set our user agent to emulate firefox 
    curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie1.txt");//set our location to store cookies
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie1.txt");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);//says we want the data that results from the request
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,0);//Do not follow redirects
    curl_setopt($ch, CURLOPT_POST,1);//yes we want to post
    curl_setopt($ch, CURLOPT_HEADER, 0);//don?t return the header
    curl_setopt($ch, CURLOPT_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 :)
 
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
 
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($post, 0, -1);    

        // send first request to ping.fm to get cookies
        $ch = curl_init(); 
        curl_setopt($ch, CURLOPT_URL,'http://ping.fm'); 
        curl_setopt($ch, CURLOPT_USERAGENT, $useragent);  
        curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie1.txt"); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1); 
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1); 
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);  
        $data=curl_exec($ch);

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

        // post to signup form
        curl_setopt($ch, CURLOPT_URL,"http://ping.fm/signup.php"); 
        curl_setopt($ch, CURLOPT_USERAGENT, $useragent);  
        curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie1.txt"); 
        curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie1.txt"); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1); 
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1);    // when you submit a form you need to follow the redirect 
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        curl_setopt($ch, CURLOPT_AUTOREFERER, 1); // when dealing with multiple pages, have curl fill out referrer 
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $data=curl_exec($ch);

        curl_close($ch);

        // echo page after signup
        echo $data;    

    }

    echo fn_pingfm ('Bob', 'bobbybobbobster123', 'grn024y45', '[email protected]'); 

?>
 
Last edited:
Thanks very much xpwizard, just got that now so ill go and play with it and see if i understand where i went wrong :)
 
Back
Top