public static function pastoid($paste) { $url = null; $post = http_build_query(array( 'paste[1][content]' => $paste, 'paste[1][type]' => 'code', 'paste[1][language]' => 'php', 'pastetitle' => substr($paste, 0, 20) )); $context = stream_context_create(array( 'http' => array ( 'method' => 'POST', 'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($post) . "\r\n", 'content' => $post ) )); if ($page = fopen('http://pastoid.com/', 'r', false, $context)) { stream_set_timeout($page, 3.5); $data = stream_get_meta_data($page); foreach ($data['wrapper_data'] as $header) { if (preg_match('#^Location:\s*(.*)$#i', $header, $match)) { $url = $match[1]; break; } } fclose($page); } return $url; }