note 95734 deleted from httprequest.send by sobak

From: Date: Sun, 04 Dec 2016 07:27:17 +0000
Subject: note 95734 deleted from httprequest.send by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208115@lists.php.net to get a copy of this message
Note Submitter: Lymber ---- Example how to use HttpRequest to post data and receive the response: <?php //set up variables $theData = '<?xml version="1.0"?> <note> <to>php.net</to> <from>lymber</from> <heading>php http request</heading> <body>i love php!</body> </note>'; $url = 'http://www.example.com'; $credentials = 'user@example.com:password'; $header_array = array('Expect' => '', 'From' => 'User A'); $ssl_array = array('version' => SSL_VERSION_SSLv3); $options = array(headers => $header_array, httpauth => $credentials, httpauthtype => HTTP_AUTH_BASIC, protocol => HTTP_VERSION_1_1, ssl => $ssl_array); //create the httprequest object $httpRequest_OBJ = new httpRequest($url, HTTP_METH_POST, $options); //add the content type $httpRequest_OBJ->setContentType = 'Content-Type: text/xml'; //add the raw post data $httpRequest_OBJ->setRawPostData ($theData); //send the http request $result = $httpRequest_OBJ->send(); //print out the result echo "<pre>"; print_r($result); echo "</pre>"; ?>

« previous php.notes (#208115) next »