PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/New folder/api/fullonsms-api.php

https://github.com/albana31/InfosysRepo
PHP | 118 lines | 80 code | 19 blank | 19 comment | 13 complexity | 4f0d3305d2302355d46246e0c5512416 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. print "stage 7 completed\n";
  48. // Check for proper login
  49. 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") )
  50. {
  51. return "invalid login";
  52. }
  53. if (trim($msg) == "" || strlen($msg) == 0)
  54. return "invalid message";
  55. $msg = urlencode(substr($msg, 0, 160));
  56. $pharr = explode(",", $phone);
  57. $refurl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
  58. curl_setopt($curl, CURLOPT_REFERER, $refurl);
  59. curl_setopt($curl, CURLOPT_URL, "http://sms.fullonsms.com/home.php");
  60. $text = curl_exec($curl);
  61. foreach ($pharr as $p)
  62. {
  63. if (strlen($p) != 10 || !is_numeric($p) || strpos($p, ".") != false)
  64. {
  65. $result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => "invalid number");
  66. continue;
  67. }
  68. $p = urlencode($p);
  69. // Send SMS
  70. curl_setopt($curl, CURLOPT_URL, 'http://sms.fullonsms.com/home.php');
  71. curl_setopt($curl, CURLOPT_REFERER, "http://sms.fullonsms.com/home.php?show=contacts");
  72. curl_setopt($curl, CURLOPT_POST, 1);
  73. curl_setopt($curl, CURLOPT_POSTFIELDS,
  74. "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");
  75. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  76. $contents = curl_exec($curl);
  77. if(strpos($contents,"window.location.href" ) && strpos($contents, 'http://sms.fullonsms.com/MsgSent.php'))
  78. {
  79. curl_setopt($curl, CURLOPT_POST, 0);
  80. curl_setopt($curl, CURLOPT_REFERER,curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
  81. curl_setopt($curl, CURLOPT_URL, "http://sms.fullonsms.com/MsgSent.php");
  82. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  83. $contents = curl_exec($curl);
  84. }
  85. //Check Message Status
  86. $pos = strpos($contents, 'SMS Sent successfully');
  87. $res = ($pos !== false) ? true : false;
  88. $result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => $res);
  89. }
  90. //echo $text;
  91. // Logout
  92. curl_setopt($curl, CURLOPT_URL, "http://sms.fullonsms.com/logout.php?LogOut=1");
  93. curl_setopt($curl, CURLOPT_POST, 1);
  94. curl_setopt($curl, CURLOPT_POSTFIELDS,"1=1");
  95. curl_setopt($curl, CURLOPT_REFERER, "http://sms.fullonsms.com/home.php");
  96. $text = curl_exec($curl);
  97. curl_close($curl);
  98. return $result;
  99. }