laravel curl php send sms to kavenegar

Solutions on MaxInterview for laravel curl php send sms to kavenegar by the best coders in the world

showing results for - "laravel curl php send sms to kavenegar"
Hanna
24 Sep 2020
1<?php
2
3$curl = curl_init();
4
5$api_key = env('KAVENEGAR_API_KEY');
6$message="message that want to send";
7$phone_number = "09196070718";
8
9curl_setopt_array($curl, array(
10  CURLOPT_URL => 'http://api.kavenegar.com/v1/'. $api_key .'/sms/send.json',
11  CURLOPT_RETURNTRANSFER => true,
12  CURLOPT_ENCODING => '',
13  CURLOPT_MAXREDIRS => 10,
14  CURLOPT_TIMEOUT => 0,
15  CURLOPT_FOLLOWLOCATION => true,
16  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
17  CURLOPT_CUSTOMREQUEST => 'POST',
18  CURLOPT_POSTFIELDS => 'receptor='. $phone_number .'&message=' . $message,
19  CURLOPT_HTTPHEADER => array(
20    'Content-Type: application/x-www-form-urlencoded'
21  ),
22));
23
24$response = curl_exec($curl);
25
26curl_close($curl);
27echo $response;
28