php - 我怎样才能克服我的服务器中的连接被拒绝问题
问题描述
我编写了一个 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'];
?>
代码中也提到了该链接。谁能帮我解决它?
提前致谢。
解决方案
推荐阅读
- python - AttributeError:模块“pkg_resources”没有属性“resource_filename”
- ios - 黑屏标签栏控制器
- jpa - Apache Meecrowave OAuth2 JPA
- python - 无法在 python 中打开 lib 'ODBC Driver 17 for SQL Server'
- azure-data-factory - 在 AzureDataFactory (V2) 中读取 DateTime 格式
- perl - PDL API 是否有符号实现?
- python - 小波变换后图像大小发生变化
- mysql - 从另一个表错误列的mysql更新不能为空
- java - 从文本输入布局 .xml 解析计算
- opengl - 透视投影,标准可视体积