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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.