Guest User

Untitled

a guest
Dec 1st, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <?php
  2.  
  3. define('VERIFY_TOKEN', 'yourownsecretstring');
  4. $method = $_SERVER['REQUEST_METHOD'];
  5.  
  6. if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == VERIFY_TOKEN) {
  7. echo $_GET['hub_challenge'];
  8. } else if ($method == 'POST') {
  9.  
  10. //Connect To Database
  11. $hostname='Your host address';
  12. $username='Your username';
  13. $password='Your password';
  14. $dbname='Your database name';
  15.  
  16. mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  17. mysql_select_db($dbname) or die(mysql_error());
  18.  
  19. $post_body = file_get_contents("php://input");
  20. $object = json_decode($post_body, true);
  21.  
  22. foreach($object->entry as $update)
  23. {
  24. // For each entry in notification, insert a row of information into the table "FaceBook"
  25. $changed_fields = $update->changed_fields[0];
  26.  
  27. $result = mysql_query("INSERT INTO FaceBook (uid, id, time, changed_fields) VALUES('$update->uid', '$update->id', '$update->time', '$changed_fields')")
  28. or die(mysql_error());
  29.  
  30. }
  31.  
  32. mysql_close();
  33. }
  34.  
  35. ?>
Add Comment
Please, Sign In to add comment