'http://www.paste2.org/new-paste', CURLOPT_POST => true, CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => array( 'lang' => 'php', 'description' => '', 'code' => trim(stream_get_contents(STDIN)), 'parent' => '0' ) ); $ch = curl_init(); foreach ($params as $key => $value) { curl_setopt($ch, $key, $value); } $response = curl_exec($ch); curl_close($ch); preg_match('/Location: (.*)/', $response, $match); echo 'http://www.paste2.org' . $match[1];