dongzen7263 2012-03-25 19:23
浏览 39
已采纳

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

I implemented a function which connects to a merchant using the curl library for Codeigniter http://codeigniter.com/wiki/Curl_library. I finished the implementation and everything worked perfectly. However we now transfered the application to a Local Server. fresh installation of: Ubuntu Server 11.10 Php 3.5.6 Mysql 5.1 Apache 2

I'm using a static Ip configuration and I can connect to the internet. Using terminal I can ping sites like google, yahoo etc, however I cant Ping www.veripayment.com. I can open the website from other computers in the same network. But my ubuntu server cant.

Please keep in mind this works in our server.

<?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条回答 默认 最新

  • dongzhang1875 2012-03-25 21:53
    关注

    What is the ping response code?

    Try raw curl like so. Then check your error log for possible solution

    $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;
            }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分