Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $inputFileName = $_FILES['SMSFile']['tmp_name'];
- $reader = ReaderFactory::create(Type::XLSX);
- $reader->open($inputFileName);
- $count = 1;
- foreach ($reader->getSheetIterator() as $sheet) {
- foreach ($sheet->getRowIterator() as $row) {
- if ($count > 1) {
- $ddate=$row[4]->format('d-M-Y');
- $ddate1=$row[5]->format('d-M-Y');
- $arr[]= array(
- 'DISTName' => $row[0],
- 'contactNo' => $row[1],
- 'sepecification' => $row[2],
- 'POD' => $row[3],
- 'dispatchDate' => $ddate,
- 'ExpectedDate' =>$ddate1
- );
- $to=$row[1];
- $Distinct= $row[0];
- $sepecification =$row[2];
- $poid = $row[3];
- $dispatchDate = $ddate;
- $ExpectedDate = $ddate1;
- $SMSUser = 'abx';
- $password = 'abxx';
- $sid = 'ABC';
- $message = "Dear Sir,nDist: $Distinct nSepecification: $sepecification nPOD: $poid nDispatch Date: n$dispatchDate nExpected Delivery: n$ExpectedDate";
- $sendSMS = $this->SendSMS->sendSMS($SMSUser, $password, $message, $to, $sid);
- }
- $count++;
- }
- $reader->close();
- }
- public static function sendSMS($user, $password, $message, $to, $sid) {
- $fl = 0;
- $gwid = 2;
- //Prepare you post parameters
- $postData = array(
- 'user' => $user,
- 'password' => $password,
- 'msisdn' => $to,
- 'sid' => $sid,
- 'msg' => $message,
- 'fl' => $fl,
- 'gwid' => $gwid,
- );
- //API URL
- $url="http://sms.example.in:8080/abc/xyz.aspx";
- // init the resource
- $ch = curl_init();
- curl_setopt_array($ch, array(
- CURLOPT_URL => $url,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $postData
- ));
- //Ignore SSL certificate verification
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- //get response
- $output = curl_exec($ch);
- //Print error if any
- if(curl_errno($ch))
- {
- echo 'error:' . curl_error($ch);
- }
- curl_close($ch);
- }
Add Comment
Please, Sign In to add comment