簡體   English   中英

來自服務器的PHP / CURL空回復

[英]PHP/CURL Empty Reply from Server

我的服務器上運行有NodeJS應用程序,我的CURL可以向服務器上應用程序的端口提交發布請求。 如果我訪問PHP頁面,我通常可以做到這一點,但是嘗試以命令行方式執行則是另一回事了。 它不斷返回HTTP響應代碼0,錯誤為“來自服務器的空回復”

PHP Curl(OOP)[$ this-> domain = http:// domain:port ,$ url = / path / to / something]:

protected function post($url, $data)
{   
    $ch = curl_init();

    curl_setopt($ch,CURLOPT_HTTPHEADER, array(
            'Content-Type: application/json',
            'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0'
    ));
    curl_setopt($ch,CURLOPT_URL,$this->domain.$url);
    curl_setopt($ch,CURLOPT_POST,count($data));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);

    $result = curl_exec($ch);
    //error_log(curl_error($ch));
    return $result;
}


命令行執行:

curl https://rbx.shopping/Secure/IPNCron.php


訪問domain:port時的默認頁面

訪問domain:port時的默認頁面


有關應返回什么的示例: https : //rbx.shopping/Bot

嘗試添加餅干罐:

$ckfile = tempnam (sys_get_temp_dir(), rand().'cookiename');
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);

還要添加以下內容:

curl_setopt($handle, CURLOPT_ENCODING, 'identity');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM