普通网友 2013-12-30 05:32
浏览 176

使用curl时出现500内部服务器错误

I am using two curl for autosuggest and fetching records.when i tested the same code on local its working fine but when i take it live gets 500 intenal server please look into this.

switch ($cases){
case 'city' :
    $obj_biz_tmp_info= new info($db_server['CITY']);
    $response_list = $obj_biz_tmp_info->getCity($string);
    $obj_biz_tmp_info->close();
    break;

case 'what' :
    if ($_GET['search'] == "") return false;

    $areasrch = $_GET['search'];

    if(!empty($areasrch)){
        $apiurl = 'http://192.168.1.97/auto.php?search='.urlencode(trim($areasrch)).'&city='.urlencode(trim($city)).'&stp=0&dtres=20&srch_type=2';
        $ch = curl_init($apiurl);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_USERPWD, "abcd");
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        $getResults = curl_exec($ch);
        curl_close($ch);
        $getResults = json_decode($getResults,true);

        echo json_encode($getResults);      
        //print_r($getResults);

        break;
    }

case 'compsearch':

    if ($_GET['search'] == "") return false;

    $areasrch1 = $_GET['search'];

    if(!empty($areasrch1)){
        $apiurl = 'http://192.168.1.97/auto.php?search='.urlencode(trim($areasrch1)).'&city='.urlencode(trim($city)).'&stp=0&dtres=20&srch_type=2';

        $ch = curl_init($apiurl);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_USERPWD, "abcd");
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        $getResults1 = curl_exec($ch);
        curl_close($ch);
        $getResults1 = json_decode($getResults1,true);
        echo json_encode($getResults1);

        //print_r($getResults1);

        break;
    }
  • 写回答

1条回答 默认 最新

  • douqiong8412 2013-12-30 06:13
    关注

    http://192.168.1.97 is an address on your local network, which is probably not accessible from your server.

    If the auto.php script is hosted on the same server, you can change this:

    $apiurl = 'http://192.168.1.97/auto.php?search=' // rest of line ommited
    

    to

    $apiurl = 'http://' . $_SERVER['HTTP_HOST'] . '/auto.php?search=' // rest of line ommited
    
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突