Send SMS Message using PHP

时间:2017-08-04 12:37:46

标签: php curl sms-gateway

I have developed a system which will send SMS to the customer after making insert to the database but the system which I worked on is public ie. when my client asked me to buy the system he must insert his SMS API configuration to send a message to his customers when I searched on the internet I found that every API have a differnt way to send SMS message I have account in click tell API but when I send message by curl there is nothing happen the code is

$url = 'https://platform.clickatell.com/messages/http/send?' . http_build_query(
    [
      'apiKey' =>  'oGjnzDdSRhqdhhgnjFj3ZmzYA==',
   //   'api_secret' => '4c98619ffb9af51585',
      'to' => '94233698311783',

      'content' => 'Hello from Netcom'
    ]
);
echo($url);echo('<br/>');
echo'https://platform.clickatell.com/messages/http/send?apiKey=oGkmzDdSRgekvjFjaZnzYA==&to=905373545631&content=Test+message+text"';
$ch = curl_init($url);
echo($ch);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

echo $response;

Where my code is wrong and what is the way to send SMS dynamically depending on the client's API info

2 个答案:

答案 0 :(得分:1)

For quick fix and testing add this in your curl request and check response.(Because url is https)

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);

But it is recomonded to downloading a CA root certificate bundle at the curl website and saving it on your server which protect your site

答案 1 :(得分:0)

I am not aware of Clickatell, but Aws SNS is quite simple,

$payload = array(

                'Message' => $message,
                'PhoneNumber' => $mobile,
                'MessageAttributes' => $msgAttributes
            );

$result = $sns->publish($payload);
相关问题