简体   繁体   中英

PHP curl post always return 500 Internal Server Error

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM