Advertisement
MattRichardson

PHP Code for Arduino Checkins

Jan 19th, 2012
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2. $checkin = stripslashes($_POST["checkin"]);
  3. $val = json_decode($checkin);
  4.  
  5. $firstname = $val->user->firstName;
  6. $lastname = $val->user->lastName;
  7.  
  8. $display = $firstname . " " . $lastname . " just checked in! Welcome, " . $firstname . "!";
  9. $display = urlencode($display);
  10.  
  11. // I'm using +++ to indicate the start of the string and &&& to indicate the end for now
  12. // I plan on writing Arduino code to interpret GET parameters so that it can be more
  13. // easily ported for other uses.
  14.  
  15. $url = "http://ARDUINO_ADDRESS_HERE/+++" . $display . "&&&";
  16.  
  17. $str = file_get_contents($url);
  18. $myFile = "logFile.txt";
  19. $fh = fopen($myFile, 'a');
  20. $checkin .= "\n\n";
  21. fwrite($fh, $checkin);
  22. fclose($fh);
  23.  
  24. echo "OK";
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement