Codeigniter Curl Library在服务器更改后无法正常工作

时间:2012-03-25 19:23:45

标签: php codeigniter curl ubuntu-11.04

我实现了一个使用代码生成器http://codeigniter.com/wiki/Curl_library的curl库连接到商家的功能。我完成了实施,一切都很完美。但是,我们现在将应用程序转移到本地服务器。全新安装: Ubuntu Server 11.10 PHP 3.5.6 Mysql 5.1 Apache 2

我正在使用静态IP配置,我可以连接到互联网。 使用终端我可以ping谷歌,雅虎等网站,但我不能Ping www.veripayment.com。我可以从同一网络中的其他计算机打开网站。但我的ubuntu服务器不能。

请记住,这可以在我们的服务器中使用。

<?php
    $post_str = "action=payment&business="
    .urlencode($this->input->post('business'))
    ."&vericode=".urlencode($this->input->post('vericode'))
    ."&item_name=".urlencode($this->input->post('item_name'))
    ."&item_code=".urlencode($this->input->post('item_code'))
    ."&quantity=".urlencode($this->input->post('quantity'))
    ."&amount=".urlencode($this->input->post('amount'))
    ."&cc_type=".urlencode($this->input->post('cc_type'))
    ."&cc_number=".urlencode($this->input->post('cc_number'))
    ."&cc_expdate=".urlencode($this->input->post('cc_expdate_year')).urlencode($this->input->post('cc_expdate_month'))
    ."&cc_security_code=".urlencode($this->input->post('cc_security_code'))
    ."&shipment=".urlencode($this->input->post('shipment'))
    ."&first_name=".urlencode($this->input->post('first_name'))
    ."&last_name=".urlencode($this->input->post('last_name'))
    ."&address=".urlencode($this->input->post('address'))
    ."&city=".urlencode($this->input->post('city'))
    ."&state_or_province=".urlencode($this->input->post('state_or_province'))
    ."&zip_or_postal_code=".urlencode($this->input->post('zip_or_postal_code'))
    ."&country=".urlencode($this->input->post('country'))
    ."&shipping_address=".urlencode($this->input->post('shipping_address'))
    ."&shipping_city=".urlencode($this->input->post('shipping_city'))
    ."&shipping_state_or_province=".urlencode($this->input->post('shipping_state_or_province'))
    ."&shipping_zip_or_postal_code=".urlencode($this->input->post('shipping_zip_or_postal_code'))
    ."&shipping_country=".urlencode($this->input->post('shipping_country'))
    ."&phone=".urlencode($this->input->post('phone'))
    ."&email=".urlencode($this->input->post('email'))
    ."&ip_address=".urlencode($this->input->post('ip_address'))
    ."&website_unique_id=".urlencode($this->input->post('website_unique_id'));

    // Send URL string via CURL
    $backendUrl = "https://www.veripayment.com/integration/index.php";
    $this->curl->create($backendUrl);
    $this->curl->post($post_str);
    $return = $this->curl->execute();

    $result = array();
    // Explode array where blanks are found
    $resparray = explode(' ', $return);

    if ($resparray)
    {
        // save results into an array
        foreach ($resparray as $resp) {
            $keyvalue = explode('=', $resp);
            if(isset($keyvalue[1])){
                $result[$keyvalue[0]] =  str_replace('"', '', $keyvalue[1]);
            }
        }
    }
    return $result;
?>

1 个答案:

答案 0 :(得分:0)

什么是ping响应代码?

尝试原始卷曲。 然后检查错误日志以获取可能的解决方案

$url = "https://www.veripayment.com/integration/index.php";
        $ch = curl_init();
        curl_setopt_array($ch, array(
            CURLOPT_URL => $url,
            CURLOPT_POST => TRUE,
            CURLOPT_POSTFIELDS => http_build_query($this->input->post()),
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_HEADER => FALSE,
            CURLOPT_SSL_VERIFYPEER => FALSE
        ));

        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        if($code === 200){

             return true;   
        }
        else
        {
             log_message('error', curl_error($ch));
             return false;
        }