http://curl.haxx.se/docs/programs.html - cURL scripts/programs http://www.zelune.net - Zelune Proxy Script [Runs on cURL]
<?php class curl { function curl( ) { if( !( $this->curl = curl_init( ) ) ) { die("cURL is not available on this server"); } elseif( !curl_setopt( $this->curl, CURLOPT_RETURNTRANSFER, true ) ) { die("cURL setup failed, please insure curl is installed properly"); } } function get( $url ) { if( !curl_setopt( $this->curl, CURLOPT_URL, $url ) ) { return false; } return curl_exec( $this->curl ); } function post( $url, $params ) { if( !curl_setopt( $this->curl, CURLOPT_POST, true ) or !curl_setopt( $this->curl, CURLOPT_POSTFIELDS, $params ) or !curl_setopt( $this->curl, CURLOPT_URL, $url ) ) { return false; } return curl_exec( $this->curl ); } function request( $method, $url, $params = null ) { if( strtolower( $method ) == 'post' ) return $this->post( $url, $params ); else return $this->get( $url ); } function multi( $jobs, &$data ) { foreach( $jobs as $count => $job ) { if( !( $data[ $count ] = $this->request( $job[0], $job[1], $job[2] ) ) ) { die( sprintf( "cURL failed with error code %s : %s", curl_errno( $this->curl ), curl_error( $this->curl ) ) ); } } } } $curl = new curl( ); $curl->multi( array( array( 'POST', 'http://krakjoe.com/post-ajax.php', 'the=data&goes=here' ), array( 'GET', 'http://msn.com', null ) ), $storage ); // $storage now contains the data from the request above // print_r( $storage ); ?> PHP:
i would recommend using http_build_query() (if using php5) to build the query string. just how i would do it so you don't have to worry about url-encoding the args it's already done. $args = array("var1"=>"value1","var2"=>"value2","var3"=>"value3"); $query_string = http_build_query($args); PHP:
and if not .... <?php $args = array("var1"=>"value1 and this next bit","var2"=>"value2 and some more url encoded stuff","var3"=>"value3 and yet more encoded stuff"); $query_string = http_build_query($args ); if( !function_exists( 'http_build_query' ) ) { function http_build_query( $array, $numeric = null ) { foreach( $array as $key => $value ) { $result[] = sprintf( '%s=%s', $key, urlencode( $value ) ); } return implode( $numeric ? $numeric : "&", $result ); } } echo $query_string ; PHP: