开发者

xml response error

开发者 https://www.devze.com 2023-04-13 07:10 出处:网络
I get SSL connection timeout error when I try sending xml message and expect a response: $xml = <<<EOL

I get SSL connection timeout error when I try sending xml message and expect a response:

$xml = <<<EOL
<?xml version='1.0' encoding='UTF-8'?> 
<abc>
<UserId>123</UserId> 
</abc>
EOL;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, arra开发者_StackOverflowy('xmlmessage' => $xml));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);

$result = curl_exec($ch);
if ($result === FALSE) {
    die(curl_error($ch));
}

echo $result

Can anyone help?


On the code above you are missing:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 

Other than that, you need to make sure curl has ssl support. Create a file named "test.php" and put the following in it:

<?php
phpinfo();
?>

then load the page via your browser. On the output, scroll down towards the "middle" of the page where you can see details about the modules installed/enabled. Look for the curl information. If it has SSL support you will see something SIMILAR to (notice how it "mentions" ssl):

cURL Information    libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6

Otherwise you'll need to contact the server admin to have him/her install ssl support for it.

0

精彩评论

暂无评论...
验证码 换一张
取 消