简体   繁体   中英

How to resolve connection refused when hit a sms api url in curl

I am sending an sms when create a new entry . I am using curl to hit the url . But in response i get "Failed connect to login.bulksmsrocket.com:8080; Connection refused".

public function send_sms($mobile,$message){
    $email="xxxx@xxxx.com";

    $sender ='Health';
    $serverUrl="login.bulksmsrocket.com";
    $authkey="xxxxx&message";
    $route="1";
    $getData='mobileNos='.$mobile.'&message='.urlencode($message).'&senderId='.$sender.'&routeId='.$route;
    $curl = curl_init();
    $url="http://login.bulksmsrocket.com/rest/services/sendSMS/sendGroupSms?AUTH_KEY=".$authkey."&".$getData;


    curl_setopt_array($curl, array(
        CURLOPT_PORT => "8080",
        CURLOPT_URL => $url,
        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(
            "Cache-Control: no-cache"
        ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
        return $err;
    } else {
        return $response;
    }
}

"Failed connect to login.bulksmsrocket.com:8080; Connection refused"

进入端口8080时,该网址似乎不起作用。删除此行:

CURLOPT_PORT => "8080",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM