Apr 4 2008

PHP post without curl

You can simulate the post method using php without the help of curl library.
download full source code:
OpenID Integration PHP

See the code below:

function do_post_request($url, $data, $optional_headers = null) {

$params = array('http' =>; array('method' =>; 'POST',

'content' =>; $data

));

if ($optional_headers !== null) {

$params['http']['header'] = $optional_headers;

}

$ctx = stream_context_create($params);

$fp = @fopen($url, 'rb', false, $ctx);

if (!$fp) {

throw new Exception("Problem with $url, $php_errormsg");

}

$response = @stream_get_contents($fp);

if ($response === false) {

throw new Exception("Problem reading data from $url, $php_errormsg");

}

return $response;

}

?>

Download the full source code from post_without_curl.zip

2 Comments on this post

Trackbacks

  1. Binny V A said:

    An easier way to do this - load() function. With and without curl

    April 4th, 2008 at 11:44 am
  2. Sajith M.R said:

    Both are almost same , i think

    April 4th, 2008 at 12:04 pm

LEAVE A COMMENT

Subscribe Form

Subscribe to Blog

Sponsors

    Advt on sajithmr.com
    Advt on sajithmr.com
    Advt on sajithmr.com
    Itslife Online

Recent Comments

  • sexasion: Best of the Best sexypicturess.blogspot.com
  • memo ezzo: live sex hot video
  • muhammadashraf44: i am ashraf from karachi i have only one girl in sex and one night plzz
  • Arun Basil Lal: Dude, The comments to this post are ever flowing in, I am gonna post some hot pics on my blog too.....
  • badar: plz send me the hot pic

Recent Readers

JOIN MY COMMUNITY!

Recent Posts