首页 > 解决方案 > 我怎样才能克服我的服务器中的连接被拒绝问题

问题描述

我编写了一个 curl 代码来运行 SMS API。它在本地主机中运行良好。当我将它上传到虚拟主机时,它显示错误,例如Failed to connect to smeapps.mobitel.lk port 8585: Connection denied

不知道怎么解决??

这是我写的代码。

<?php
// Your ID and token

//Content-Type: application/json
 //Accept: application/json
//header('Content-Type: application/json');
//header('Accept: application/json');

$blogID = 'xxxxxx';
$authToken = 'xxxxx';

// The data to send to the API
$postData = array(
    'username' => 'xxxxx',
    'password' => 'xxxx',
    'from' => 'xxxx',
    'to' => '07612xxxxx',
    'text'=>'hello',
    'messageType'=>0
);





// Setup cURL
$ch = curl_init('http://smeapps.mobitel.lk:8585/EnterpriseSMSV3/esmsproxyURL.php');
curl_setopt_array($ch, array(
    CURLOPT_POST => TRUE,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_HTTPHEADER => array(
        'Authorization: '.$authToken,
        'Content-Type: application/json',
        'Accept: application/json'
    ),
    CURLOPT_POSTFIELDS => json_encode($postData)
));

// Send the request
$response = curl_exec($ch);

// Check for errors
if($response === FALSE){
    die(curl_error($ch));
}

// Decode the response
$responseData = json_decode($response, TRUE);

// Print the date from the response
//echo $responseData['published'];

?>

代码中也提到了该链接。谁能帮我解决它?

提前致谢。

标签: phpjsonapicurlsoap

解决方案


推荐阅读