dtqysxw4659 2016-04-02 18:15
浏览 608

PHP curl post总是返回500内部服务器错误

I'm trying to make a php curl to make a post in this link: http://g3cs.uesc.com/dsse1.asp, doing it in browser it works fine, ie: put some code like: 41225295 at input field and click at button it will make a post to http://g3cs.uesc.com/dsse2.asp, my code is:

<?php
function __curl($url,$p=NULL,$h=NULL,$ssl=0,$c=NULL,$tm=690,$header=0)
{
    $ch = curl_init();
    $opts = array(
    CURLOPT_URL => $url,
    CURLOPT_HEADER => $header,
    CURLOPT_FOLLOWLOCATION => 1,
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_SSL_VERIFYPEER => $ssl,
    CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)',
    CURLOPT_TIMEOUT => $tm,
    CURLOPT_REFERER => 'http://g3cs.uesc.com/dsse1.asp'
    );

    if($p)
    {
        $opts[CURLOPT_CUSTOMREQUEST] = 'POST';
        $opts[CURLOPT_POST] = 1;
        $opts[CURLOPT_POSTFIELDS] = http_build_query($p);
    }
    if($h) $opts[CURLOPT_HTTPHEADER] = $h;
    if($c) $opts[CURLOPT_COOKIE] = $c;

    curl_setopt_array($ch,$opts);
    $out = curl_exec($ch);

    if(!$out)
    {
        echo curl_error($ch);
        exit(0);
    }

    curl_close($ch);

    return $out;
}

echo __curl('http://g3cs.uesc.com/dsse2.asp',array('opt'=>'0','inacn'=>'127','inref'=>'41225295'));
?>

it always return 500 Internal Server Error.

someone could help me with some hints?

Thanks.

  • 写回答

1条回答 默认 最新

  • douxie7339 2016-04-02 18:37
    关注

    Can you make sure the server-side script (dsse2.asp) has no issues. I strongly believe Status 500 is something related to server-side script. it has nothing to do with your client

    评论

报告相同问题?

悬赏问题

  • ¥15 关于下拉菜单选项关联的问题
  • ¥15 如何修改pca中的feature函数
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R