<?php
$url='http://www.stumbleupon.com/signup.php?pre=homepage';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 35);
curl_setopt($ch, CURLOPT_TIMEOUT, 35);
$data = curl_exec($ch);
$pattern='/<input type=\"hidden\" name=\"ftoken\" value=\"(.*?)\"/si';
preg_match($pattern,$data,$match);
$token=$match[1];