Skip to content

Z1. PHP (curl)

Yohannes Mekonnen edited this page Sep 5, 2023 · 1 revision

# Sending SMS to a Single Phone with PHP - curl

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'your_single_url',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
      "username": "your_username",
      "password": "your_password",
      "to": "9xxxxxxxx", 
      "text": "your_message"
}',
    CURLOPT_HTTPHEADER => array(
        'Content-Type: application/json'
    ),
));

$response = curl_exec($curl);
curl_close($curl);

echo $response;

# Sending SMS to a Multiple Phone with PHP - curl

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'your_list_url',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
      "username": "your_username",
      "password": "your_password",
      "to": ["9xxxxxxxxx", "9xxxxxxxxx", "9xxxxxxxxx"],
      "text": "your_message"
}',
    CURLOPT_HTTPHEADER => array(
        'Content-Type: application/json'
    ),
));

$response = curl_exec($curl);
curl_close($curl);

echo $response;
Clone this wiki locally