jesobreira

freesms4us

Nov 6th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 KB | None | 0 0
  1. <?php
  2. /**
  3.     @description A function to receive SMS from FreeSMS4Us.com
  4.     @author Jefrey S. Santos <jesobreira[at]yahoo[dot]com[dot]br>
  5.     THIS FILE IS PRIVATE. NO RELEASE ALLOWED. ---------------\
  6.     ILLEGAL PUBLISHERS WILL BE RESPONSIBLE, ACCORDING TO     |
  7.     FOLLOWING COPYRIGHT INFRINGEMENT LAWS:                   |
  8.         - 18 U. S. C. § 2, 2319                          |
  9.         - 17 U. S. C. § 506                              |
  10.         - 18 U. S. C. §. 371                             |
  11.                                                                  |
  12.     (kidding, my love kkkkk ;) <-----------------------------/
  13.  
  14. Example output:
  15. Irene (083830637802)
  16. Array
  17. (
  18.     [0] => U ALREADY DIE? WHY U DONT REPLY MY TEXT MESSAGE!!!!!!
  19.     [1] => JEFREY!!!!!!!!
  20.     [2] => Heeyyy!
  21.     [3] => Yeah
  22.     [4] => No
  23.     [5] => Idk bored
  24.     [6] => Not funny
  25.     [7] => Not funny
  26.     [8] => Good night. Im bored, make something funny or make me suprised
  27.     [9] => No!-_- gonna watch my favorite movie
  28.     [10] => Why crazy?
  29.     [11] => Im at home! Now i wanna take a bath
  30.     [12] => No after this ill have lesson
  31.     [13] => I already go to bsktbll club, n now im at home
  32.     [14] => I hav arrvd at home
  33.     [15] => Ok later if i can open my fb ill reply ur message.. Now i wanna go to basketball club
  34.     [16] => Kkkkk how r u?
  35.     [17] => Okayyy
  36.     [18] => Yeah thank you :)
  37.     [19] => Different number phone again?
  38.     [20] => Miss u too
  39.     [21] => Thankyou :D  Have a nice dream
  40.     [22] => Jefrey :D
  41. )
  42.  
  43.  
  44. */
  45. function getsms($number) {
  46.     $ch = curl_init();
  47.     curl_setopt($ch, CURLOPT_URL, "http://freesms4us.com/reply.php");
  48.     curl_setopt($ch, CURLOPT_POST, true);
  49.     curl_setopt($ch, CURLOPT_POSTFIELDS, "nomer=$number");
  50.     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
  51.     curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  52.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  53.     $store = curl_exec($ch);
  54.     $store = strip_tags($store);
  55.  
  56.     $store = explode("\n", $store);
  57.     $store = array_map("trim", $store);
  58.  
  59.     $msgs = array();
  60.  
  61.     foreach($store as $line) {
  62.         $pattern = "/^SMS no:\-[0-9]*\. [&nbsp;]{4}(.*) \)(.*)$/";
  63.         if(preg_match($pattern, $line)) {
  64.             $res = array();
  65.             preg_match_all($pattern, $line, $res);
  66.             if(count($res)) {
  67.                 $msgs[] = $res[2][0];
  68.             }
  69.         }
  70.     }
  71.  
  72.     return sizeof($msgs) ? $msgs : false;
  73. }
  74.  
  75. $nbr = array();
  76. $nbr['Irene'] = "083830637802";
  77.  
  78. foreach($nbr as $name=>$num) {
  79.     echo "\n$name ($num)\n";
  80.     print_r(getsms($num));
  81. }
Add Comment
Please, Sign In to add comment