note 67825 deleted from function.fsockopen by nlopess
| From: | nlopess@php.net | Date: | Wed, 05 Jul 2006 20:12:00 +0000 |
| Subject: | note 67825 deleted from function.fsockopen by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-114407@lists.php.net to get a copy of this message | ||
Note Submitter: php at macosbrain dot com
----
i just create a small class that handle requests to websites over php.
-it include post/get/...
-you can set cookies
-upload files
-add custom header information
-and much more
information (in german) and a zip file with the download under:
http://macosbrain.ath.cx/wordpress/2006/07/02/http-request-mit-php/
here just a usage examlpe. the code was to long for a note in php.net.
<?php
//Usage example:
////method, host, file, port(optional), http_v(optional)
//$request = new
http_request('POST','macosbrain','/nvtracker/test.php');
////use a proxy server for request -> optional
//$request->proxy('192.168.0.1',8080);
////add some header informations
//$request->add_header('Accept','text/plain');
////add some header informations
//$request->add_header('User-Agent','Firefox/1.5.0.4');
////add some header informations
//$request->add_header('Referer','http://localhost');
//$cookies = array(
//'uid' => 3,
//'pass' => 'testpass',
//'PHPSESSID' => '123456789');
//$request->add_cookies($cookies); /// add the cookies to the request
//$request->add_data('disk','on'); // add "disk" with value
"on"
//$request->add_data('test','123');// add "test" with value
"123"
////add a real file, with fake name(like an upload)
//$request->add_file('file_1', "test.jpg",
$request->get_bin_file_content('C:\\small.JPG'));
////add a custom "file" (like an upload)
//$request->add_file('file_2',"nice_dummy.txt",'content in the
file');
//$request->send();///send the request
//echo('---------packet send--------');
//print_r($request->packet);
//echo('---------send_header---------');
//print_r($request->send_header);
//echo('---------send_data---------');
//print_r($request->send_data);
//echo('---------response from host---------');
//print_r($request->response);
?>