PHP Curl通信错误到内部服务器

时间:2018-06-18 14:26:57

标签: php php-curl

我正在尝试使用此代码在PHP中使用包含用户,密码和会话的Curl通信来上传文件。

之后,我收到错误Https 400.我尝试使用其他信息修复它但仍然卡住

$url = 'https://mysite/ses/upload';  // url name

// making array with file, password, username and connection

$uploadRequest = array(
    'file' => 'request/first-last-20180615191901.270',
    'username' => 'USER',
    'password' => 'Password',
    'connection' => 'HETS_SESEACCI001',
);

// initializing curl 

$curl = curl_init();

// for avoiding ssl self signed certificate error 

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

// now drafting all details with parameters 

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $uploadRequest);


$response = curl_exec($curl);

// if error display error

if(curl_error($curl)) { 
   echo 'Curl error :- ' . curl_error($curl);
} else {
    // creating response file and pass to response.php for parsing
    if ($response) {
        $responsefilename = $output['firstName'].'-'.$output['lastName'].'-'.$output['Timestamp'].'.271';
        $responsedirectory = "response/";
        $responsefile = $responsedirectory.$responsefilename;
        $file2 = fopen($responsefile,'w+') or die("Unable to open response file!");
        fwrite($file2,$response);
        fclose($file2);
        $_SESSION['response-file'] = $responsefile;
        header("Location: response.php");
    };
}
curl_close($curl);

//通讯错误

enter code here
HTTP ERROR: 400
Problem accessing /ses/upload. Reason:

Missing request body

0 个答案:

没有答案