2017-04-03 7 views
0

私はNodeJSアプリケーションをサーバー上で実行しており、私のサーバー上のどこにアプリケーションのポートに投稿要求を送信するCURLを持っています。私はPHPページにアクセスすれば正常に実行できますが、コマンドラインとして実行しようとすると別の話です。これは、HTTPレスポンスコード0とPHP/CURL空サーバーからの返信

PHPカール(OOP)[ます$ this->ドメイン= http://domain:port、$のURL = /パス/に/何か] "サーバーから空の返信" というエラーで戻って続け:

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 


デフォルトページドメイン訪問: https://rbx.shopping/Bot

答えて

0

は、クッキージャーを追加しよう:

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

返却しなければならないものにポート

Default Page when visiting domain:port


例また、これを追加してください:

curl_setopt($handle, CURLOPT_ENCODING, 'identity'); 
関連する問題