无法连接到rslr.connectbind.com端口8080:连接被拒绝

时间:2019-01-28 05:33:32

标签: php

PHP CURL拒绝打开连接

当我在浏览器中调用此URL时,它将打开并发送短信

http://rslr.connectbind.com:8080/bulksms/bulksms?username=josy-mbongocash&password=kipese73&type=0&dlr=1&destination=254719401837&source=MbongoCash&message=METHODE-PATRICK

响应正常:1701 | 254719401837 | e8fbf5af-d7c2-4f34-a80f-94803ffee9d5

当我尝试用curl调用它时

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://rslr.connectbind.com:8080/bulksms/bulksms?
username=josy-
mbongocash&password=kipese73&type=0&dlr=1&destination=254719401837&
source=MbongoCash&message=METHODE-PATRICK",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Postman-Token: 09ba239d-fcb7-4755-8032-7ff4f768147f",
"cache-control: no-cache"
),
));
 $response = curl_exec($curl);
 $err = curl_error($curl);

 curl_close($curl);

 if ($err) {
 echo "cURL Error #:" . $err;
} else {
echo $response;
}

响应:无法连接到rslr.connectbind.com端口8080:连接被拒绝

2 个答案:

答案 0 :(得分:0)

问题是我更改了端口并且可以正常工作

答案 1 :(得分:0)

使用CURL

$url="http://rslr.connectbind.com/bulksms/bulksms";
$ch = curl_init();

$variables = array(
    'username' => 'Your user name',
    'password' => 'Your password',
    'type' => '0',
    'dlr' => '1',
    'destination' => "Mobile number with country code", 
    'source' => 'Brand Name',
    'message' => "sms",
);

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $variables);

echo $result = curl_exec($ch);

没有CURL

$url="http://rslr.connectbind.com/bulksms/bulksms";
$variables = array(
    'username' => 'Your user name',
    'password' => 'Your password',
    'type' => '0',
    'dlr' => '1',
    'destination' => "Mobile number with country code", 
    'source' => 'Brand Name',
    'message' => "sms",
);

$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($variables),
    ),
);


$context  = stream_context_create($options);
echo $result = file_get_contents($url, false, $context);
相关问题