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:
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
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