Answers for "laravel curl php send sms to kavenegar"

PHP
0

laravel curl php send sms to kavenegar

<?php

$curl = curl_init();

$api_key = env('KAVENEGAR_API_KEY');
$message="message that want to send";
$phone_number = "09196070718";

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://api.kavenegar.com/v1/'. $api_key .'/sms/send.json',
  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 => 'receptor='. $phone_number .'&message=' . $message,
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Posted by: Guest on July-16-2021

Browse Popular Code Answers by Language