Jump to content
  • 0

Обмен данными между скриптами


Radiocity
 Share

Question

Приветствую. Необходимо отправить запрос на сервер и получить ответ. Использую для этого curl. Но ответа не получаю.

Не подскажите в чем может быть проблема?


<?php
ini_set('register_globals',0);
?>
<html>
<head><title>TEST</title></head>
<body>

<?php
$host = "target.com";
$port = 443;
$path = "/cgi-bin/cgi_link";

$formdata = array (
'AMOUNT' => '1',
'CURRENCY' => 'RUB',
'ORDER' => '1',
'DESC' => 'test',
'MERCH_NAME' => '1',
'MERCH_URL' => '1',
'MERCHANT' => '1146',
'TRTYPE' => '0',
'COUNTRY' => '',
'MERC_GMT' => '+4',
'TIMESTAMP' => date('YmdHis'), //YYYYMMDDHHMMSS
'BACKREF' =>'http://victim.com/callback.php');

//build the post string
$poststring = '';
foreach($formdata AS $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
}
// strip off trailing ampersand
$poststring = substr($poststring, 0, -1);

$CR = curl_init();
curl_setopt($CR, CURLOPT_URL, "https://".$host.$path);
curl_setopt($CR, CURLOPT_POST, 1);
curl_setopt($CR, CURLOPT_FAILONERROR, true);
curl_setopt($CR, CURLOPT_POSTFIELDS, $poststring);
curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec( $CR );
curl_close($CR);
echo $result;

?>

<div style="background:#069; color:white; font-size:10px; clear:both;">
<?php

echo 'QSTRING:'.$_SERVER['QUERY_STRING'].'<br/>';
echo str_replace('&','<br/>',$poststring);
?>
</div>
</body>
</html>

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Как это правильно сделать? CURLINFO_HTTP_CODE Возвращает нуль Q_Q


<?php
//...
$CR = curl_init();
curl_setopt($CR, CURLOPT_URL, "https://".$host.$path);
curl_setopt($CR, CURLOPT_POST, 1);
//curl_setopt($CR, CURLOPT_FAILONERROR, true);
curl_setopt($CR, CURLOPT_POSTFIELDS, $poststring);
curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec( $CR );
$http_status = curl_getinfo($CR, CURLINFO_HTTP_CODE);
echo $http_status.'<hr/>';
curl_close($CR);
echo $result
//...
?>

При этом, проблема только с https://. При отправке на http://htmlbook.ru выдает 200(т.е. Ok)

Edited by Radiocity
Link to comment
Share on other sites

  • 0

Получил следующее:


Array (
[url] => https://target.com/cgi-bin/cgi_link
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.015173
[namelookup_time] => 0.002257
[connect_time] => 0.015174
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[errno] => 35
[errmsg] => error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
[content] => )

Edited by Radiocity
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy