Jump to content

http_post_fields problem !


php new bie

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/207957-http_post_fields-problem/
Share on other sites

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);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.