File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed
Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 2525 ],
2626 'slack ' => [
2727 'url ' => env ('IRANIANSMS_SLACK_URL ' )
28+ ],
29+ 'parsasms ' => [
30+ 'gateway ' => env ('IRANIANSMS_PARSASMS_GATEWAY ' ,'http://api.parsasms.com/v2/sms/send/simple ' ),
31+ 'api_key ' => env ('IRANIANSMS_PARSASMS_APIKEY ' ,'test ' ),
32+ 'sender ' => env ('IRANIANSMS_PARSASMS_SENDER ' ,'test ' )
2833 ]
2934];
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tartan \IranianSms \Adapter ;
4+
5+ use Ghasedak \GhasedakApi ;
6+
7+ class ParsaSms extends AdapterAbstract implements AdapterInterface
8+ {
9+
10+ private $ credential = [
11+ 'gateway ' => '' ,
12+ 'api_key ' => '' ,
13+ 'sender ' => ''
14+ ];
15+
16+ public function __construct ()
17+ {
18+ $ this ->credential ['gateway ' ] = config ('iranian_sms.parsasms.gateway ' );
19+ $ this ->credential ['api_key ' ] = config ('iranian_sms.parsasms.api_key ' );
20+ $ this ->credential ['sender ' ] = config ('iranian_sms.parsasms.sender ' );
21+ }
22+
23+ public function send (String $ number , String $ message )
24+ {
25+ $ number = $ this ->filterNumber ($ number );
26+ $ sender = $ this ->credential ['sender ' ];
27+ $ api_key = $ this ->credential ['api_key ' ];
28+
29+ $ curl = curl_init ();
30+ curl_setopt_array ($ curl , array (
31+ CURLOPT_URL => $ this ->credential ['gateway ' ],
32+ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 ,
33+ CURLOPT_CUSTOMREQUEST => "POST " ,
34+ CURLOPT_POSTFIELDS => "message= $ message &sender= $ sender &Receptor= $ number " ,
35+ CURLOPT_CONNECTTIMEOUT => 5 ,
36+ CURLOPT_TIMEOUT => 5 ,
37+ CURLOPT_HTTPHEADER => array (
38+ "apikey: $ api_key " ),
39+ CURLOPT_RETURNTRANSFER => true ,
40+ ));
41+
42+ $ response = curl_exec ($ curl );
43+ curl_close ($ curl );
44+
45+ return $ response ;
46+ }
47+ }
Original file line number Diff line number Diff line change 55use Tartan \IranianSms \Adapter \Ghasedak ;
66use Tartan \IranianSms \Adapter \MehrAfzar ;
77use Tartan \IranianSms \Adapter \KaveNegar ;
8+ use Tartan \IranianSms \Adapter \ParsaSms ;
89use Tartan \IranianSms \Adapter \Slack ;
910use Tartan \IranianSms \Adapter \SmsIr ;
1011use Tartan \IranianSms \Adapter \SmsLog ;
@@ -42,6 +43,9 @@ public function make($adapter = '')
4243 case 'ghasedak ' :
4344 return new Ghasedak ();
4445 break ;
46+ case 'parsasms ' :
47+ return new ParsaSms ();
48+ break ;
4549 default :
4650 throw new Exception ('Adapter not defined ' );
4751 break ;
You can’t perform that action at this time.
0 commit comments