$host, 'User-Agent' => 'API-requester', 'Accept' => '*/*', 'Connection' => 'close', 'Content-Type' => 'application/x-www-form-urlencoded', 'Content-Length' => strlen($content) ); $request = 'POST '.$path.' HTTP/1.0'; foreach ($headers as $key=>$value) $request .= $crlf.$key.': '.$value; $request .= $crlf.$crlf.$content; fputs($h, $request); $response = ''; while (!feof($h)) $response .= fgets($h); fclose($h); if (!preg_match('/^HTTP\/1\.0|1 ([0-9]+)/', $response, $r)) return FALSE; $http_code = intval($r[1]); if ($http_code != 200) return FALSE; $body_at = strpos($response, $crlf.$crlf); if ($body_at===FALSE) return FALSE; return substr($response, $body_at+strlen($crlf)*2); }