php new bie Posted July 16, 2010 Share Posted July 16, 2010 hello, I write a script using http_post_fields , the script work on my local host using easyphp .. When I upload it to my host service , it gives me an error to undefined function http_post_fields .. OK I know the problem ! the pecl_http extension not installed , So I contact my service provider and there is no replay .. my Q : any alternative function or code similar to http_post_fields thanks Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 16, 2010 Share Posted July 16, 2010 Please post your script between tags. Ken Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 16, 2010 Share Posted July 16, 2010 function http_post_lite($url, $data, $headers=null) { $data = http_build_query($data); $opts = array('http' => array('method' => 'POST', 'content' => $data)); if($headers) { $opts['http']['header'] = $headers; } $st = stream_context_create($opts); $fp = fopen($url, 'rb', false, $st); if(!$fp) { return false; } return stream_get_contents($fp); } Quote Link to comment Share on other sites More sharing options...
php new bie Posted July 16, 2010 Author Share Posted July 16, 2010 AbraCadaver , it works , Thank you very very much Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.