Guest User

Untitled

a guest
Aug 23rd, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. $inputFileName = $_FILES['SMSFile']['tmp_name'];
  2. $reader = ReaderFactory::create(Type::XLSX);
  3. $reader->open($inputFileName);
  4. $count = 1;
  5.  
  6. foreach ($reader->getSheetIterator() as $sheet) {
  7. foreach ($sheet->getRowIterator() as $row) {
  8. if ($count > 1) {
  9. $ddate=$row[4]->format('d-M-Y');
  10. $ddate1=$row[5]->format('d-M-Y');
  11.  
  12. $arr[]= array(
  13. 'DISTName' => $row[0],
  14. 'contactNo' => $row[1],
  15. 'sepecification' => $row[2],
  16. 'POD' => $row[3],
  17. 'dispatchDate' => $ddate,
  18. 'ExpectedDate' =>$ddate1
  19. );
  20.  
  21. $to=$row[1];
  22. $Distinct= $row[0];
  23. $sepecification =$row[2];
  24. $poid = $row[3];
  25. $dispatchDate = $ddate;
  26. $ExpectedDate = $ddate1;
  27. $SMSUser = 'abx';
  28. $password = 'abxx';
  29. $sid = 'ABC';
  30. $message = "Dear Sir,nDist: $Distinct nSepecification: $sepecification nPOD: $poid nDispatch Date: n$dispatchDate nExpected Delivery: n$ExpectedDate";
  31.  
  32.  
  33. $sendSMS = $this->SendSMS->sendSMS($SMSUser, $password, $message, $to, $sid);
  34.  
  35. }
  36.  
  37.  
  38.  
  39. $count++;
  40.  
  41. }
  42.  
  43. $reader->close();
  44. }
  45.  
  46. public static function sendSMS($user, $password, $message, $to, $sid) {
  47. $fl = 0;
  48. $gwid = 2;
  49. //Prepare you post parameters
  50. $postData = array(
  51. 'user' => $user,
  52. 'password' => $password,
  53. 'msisdn' => $to,
  54. 'sid' => $sid,
  55. 'msg' => $message,
  56. 'fl' => $fl,
  57. 'gwid' => $gwid,
  58. );
  59. //API URL
  60. $url="http://sms.example.in:8080/abc/xyz.aspx";
  61.  
  62. // init the resource
  63. $ch = curl_init();
  64. curl_setopt_array($ch, array(
  65. CURLOPT_URL => $url,
  66. CURLOPT_RETURNTRANSFER => true,
  67. CURLOPT_POST => true,
  68. CURLOPT_POSTFIELDS => $postData
  69. ));
  70. //Ignore SSL certificate verification
  71. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  72. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  73. //get response
  74. $output = curl_exec($ch);
  75. //Print error if any
  76. if(curl_errno($ch))
  77. {
  78. echo 'error:' . curl_error($ch);
  79. }
  80. curl_close($ch);
  81. }
Add Comment
Please, Sign In to add comment