PageRenderTime 58ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/Shell/sms/fullonsms-api.php

https://bitbucket.org/rovinbhandari/programming_scripting
PHP | 117 lines | 79 code | 19 blank | 19 comment | 13 complexity | 6fa9bc7944079506532b44881913d233 MD5 | raw file
  1. <?php
  2. /**
  3. * sendFullonSMS
  4. * Function to send to sms to single/multiple people via FullonSMS
  5. * @author Kingster
  6. * @category SMS
  7. * @example sendFullonSMS ( '9000012345' , 'password' , '987654321,9876501234' , 'Hello World')
  8. * @url https://github.com/kingster/FullonSMS-API/
  9. * @return String/Array
  10. * Please use this code on your own risk. The author is no way responsible for the outcome arising out of this
  11. * Good Luck!
  12. **/
  13. function sendFullonSMS($uid, $pwd, $phone, $msg)
  14. {
  15. $curl = curl_init();
  16. $timeout = 30;
  17. $result = array();
  18. $headers = array();
  19. $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
  20. $headers[] = 'Connection: Keep-Alive';
  21. $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
  22. $headers[] = 'Accept-Language: en-us,en;q=0.5';
  23. $headers[] = 'Accept-Encoding gzip,deflate';
  24. $headers[] = 'Keep-Alive: 300';
  25. $headers[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
  26. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  27. //curl_setopt($curl, CURLOPT_HEADER, 1);
  28. curl_setopt($curl, CURLOPT_URL, "http://sms.fullonsms.com/login.php");
  29. curl_setopt($curl, CURLOPT_POST, 1);
  30. curl_setopt($curl, CURLOPT_POSTFIELDS, "MobileNoLogin=".$uid."&LoginPassword=".$pwd."&x=64&y=5&red=");
  31. //curl_setopt($curl , CURLOPT_PROXY , '10.3.100.211:8080' );
  32. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  33. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
  34. curl_setopt($curl, CURLOPT_COOKIESESSION, 1);
  35. curl_setopt($curl, CURLOPT_COOKIEFILE, "cookie_fullonsms");
  36. curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie_fullonsms");
  37. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  38. curl_setopt($curl, CURLOPT_MAXREDIRS, 20);
  39. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  40. curl_setopt($curl, CURLOPT_USERAGENT, "iPhone 4.0");
  41. curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
  42. curl_setopt($curl, CURLOPT_REFERER, "http://sms.fullonsms.com/login.php");
  43. $text = curl_exec($curl);
  44. // Check if any error occured
  45. if (curl_errno($curl))
  46. return "access error : ". curl_error($curl);
  47. // Check for proper login
  48. if(!stristr($text,"http://sms.fullonsms.com/landing_page.php") && !stristr($text,"http://sms.fullonsms.com/home.php?show=contacts") &&!stristr($text, "http://sms.fullonsms.com/action_main.php") )
  49. {
  50. return "invalid login";
  51. }
  52. if (trim($msg) == "" || strlen($msg) == 0)
  53. return "invalid message";
  54. $msg = urlencode(substr($msg, 0, 160));
  55. $pharr = explode(",", $phone);
  56. $refurl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
  57. curl_setopt($curl, CURLOPT_REFERER, $refurl);
  58. curl_setopt($curl, CURLOPT_URL, "http://sms.fullonsms.com/home.php");
  59. $text = curl_exec($curl);
  60. foreach ($pharr as $p)
  61. {
  62. if (strlen($p) != 10 || !is_numeric($p) || strpos($p, ".") != false)
  63. {
  64. $result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => "invalid number");
  65. continue;
  66. }
  67. $p = urlencode($p);
  68. // Send SMS
  69. curl_setopt($curl, CURLOPT_URL, 'http://sms.fullonsms.com/home.php');
  70. curl_setopt($curl, CURLOPT_REFERER, "http://sms.fullonsms.com/home.php?show=contacts");
  71. curl_setopt($curl, CURLOPT_POST, 1);
  72. curl_setopt($curl, CURLOPT_POSTFIELDS,
  73. "ActionScript=%2Fhome.php&CancelScript=%2Fhome.php&HtmlTemplate=%2Fvar%2Fwww%2Fhtml%2Ffullonsms%2FStaticSpamWarning.html&MessageLength=140&MobileNos=$p&Message=$msg&Gender=0&FriendName=Your+Friend+Name&ETemplatesId=&TabValue=contacts");
  74. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  75. $contents = curl_exec($curl);
  76. if(strpos($contents,"window.location.href" ) && strpos($contents, 'http://sms.fullonsms.com/MsgSent.php'))
  77. {
  78. curl_setopt($curl, CURLOPT_POST, 0);
  79. curl_setopt($curl, CURLOPT_REFERER,curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
  80. curl_setopt($curl, CURLOPT_URL, "http://sms.fullonsms.com/MsgSent.php");
  81. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  82. $contents = curl_exec($curl);
  83. }
  84. //Check Message Status
  85. $pos = strpos($contents, 'SMS Sent successfully');
  86. $res = ($pos !== false) ? true : false;
  87. $result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => $res);
  88. }
  89. //echo $text;
  90. // Logout
  91. curl_setopt($curl, CURLOPT_URL, "http://sms.fullonsms.com/logout.php?LogOut=1");
  92. curl_setopt($curl, CURLOPT_POST, 1);
  93. curl_setopt($curl, CURLOPT_POSTFIELDS,"1=1");
  94. curl_setopt($curl, CURLOPT_REFERER, "http://sms.fullonsms.com/home.php");
  95. $text = curl_exec($curl);
  96. curl_close($curl);
  97. return $result;
  98. }