function post($url, $postdata, $ip = null, $timeout = 10)
    {
        // set url to post to
        curl_setopt($this->ch, CURLOPT_URL, $url);

        // return into a variable rather than displaying it
        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);

        //bind to specific ip address if it is sent trough arguments
        if ($ip)
        {
            if ($this->debug)
            {
                echo "Binding to ip $ip\n";
            }
            curl_setopt($this->ch, CURLOPT_INTERFACE, $ip);
        }

        //set curl function timeout to $timeout
        curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);

        //set method to post
        if (empty($this->httpMethod))
        {
            curl_setopt($this->ch, CURLOPT_POST, true);
        }

        //generate post string
        $post_array = array();
        if (is_array($postdata))
        {
            foreach ($postdata as $key => $value)
            {
                $post_array[] = urlencode($key) . "=" . urlencode($value);
            }

            $post_string = implode("&", $post_array);

            if ($this->debug)
            {
                echo "Url: $url\nPost String: $post_string\n";
            }
        }
        else
        {
            $post_string = $postdata;
        }

        // set post string
        curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_string);

        return $this->execute();
    }
function post($url, $postdata, $ip = null, $timeout = 10)
    {
        // set url to post to
        curl_setopt($this->ch, CURLOPT_URL, $url);

        // return into a variable rather than displaying it
        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);

        //bind to specific ip address if it is sent trough arguments
        if ($ip)
        {
            if ($this->debug)
            {
                echo "Binding to ip $ip\n";
            }
            curl_setopt($this->ch, CURLOPT_INTERFACE, $ip);
        }

        //set curl function timeout to $timeout
        curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);

        //set method to post
        if (empty($this->httpMethod))
        {
            curl_setopt($this->ch, CURLOPT_POST, true);
        }

        //generate post string
        $post_array = array();
        if (is_array($postdata))
        {
            foreach ($postdata as $key => $value)
            {
                $post_array[] = urlencode($key) . "=" . urlencode($value);
            }

            $post_string = implode("&", $post_array);

            if ($this->debug)
            {
                echo "Url: $url\nPost String: $post_string\n";
            }
        }
        else
        {
            $post_string = $postdata;
        }

        // set post string
        curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_string);

        return $this->execute();
    }
function post ( $ url , $ postdata , $ ip = null , $ timeout = 10 ) { // set url to post to curl_setopt ( $ this -> ch , CURLOPT_URL , $ url ) ; // return into a variable rather than displaying it curl_setopt ( $ this -> ch , CURLOPT_RETURNTRANSFER , true ) ; //bind to specific ip address if it is sent trough arguments if ( $ ip ) { if ( $ this -> debug ) { echo "Binding to ip $ip\n" ; } curl_setopt ( $ this -> ch , CURLOPT_INTERFACE , $ ip ) ; } //set curl function timeout to $timeout curl_setopt ( $ this -> ch , CURLOPT_TIMEOUT , $ timeout ) ; //set method to post if ( empty ( $ this -> httpMethod ) ) { curl_setopt ( $ this -> ch , CURLOPT_POST , true ) ; } //generate post string $ post_array = array ( ) ; if ( is_array ( $ postdata ) ) { foreach ( $ postdata as $ key => $ value ) { $ post_array [ ] = urlencode ( $ key ) . "=" . urlencode ( $ value ) ; } $ post_string = implode ( "&" , $ post_array ) ; if ( $ this -> debug ) { echo "Url: $url\nPost String: $post_string\n" ; } } else { $ post_string = $ postdata ; } // set post string curl_setopt ( $ this -> ch , CURLOPT_POSTFIELDS , $ post_string ) ; return $ this -> execute ( ) ; }
Send post data to target URL
return data returned from url or false if error occured
@param string $url
@param mixed $postdata data (assoc array ie. $foo['post_var_name'] = $value or as string like var=val1&var2=val2)
@param string $ip address to bind (default null)
@param int $timeout in sec for complete curl operation (default 10)
@return string data
@access public
Send post data to target URL return data returned from url or false if error occured