Guest User

Untitled

a guest
Apr 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. 9 <script>
  2. 10 function check() {
  3. 11 //better than the way that fb wiki describes
  4. 12 var perms = 'email,user_location,offline_access';
  5. 13
  6. 14 FB.ui({
  7. 15 method : 'permissions.request',
  8. 16 perms : perms,
  9. 17 display : 'page'
  10. 18 }, function (response) {
  11. 19 if (response.perms = perms) {
  12. 20 FB.api('/me', function (response) {
  13. 21 $.get('checkentry.php', {
  14. 22 'id': response.id,
  15. 23 'week': '<?php echo $week; ?>'
  16. 24 }, function (data) {
  17. 25 if (data.go == 'TRUE') {
  18. 26 if (data.known == 'TRUE') {
  19. 27 //go to the form and pull their details from the db if we already have been authorized
  20. 28 $('body').load('?guess=1&fbid='+response.id);
  21. 29 } else {
  22. 30 FB.getLoginStatus(function(response) {
  23. 31 if (response.session) {
  24. 32 //go to the form
  25. 33 $('body').load('?entry');
  26. 34 } else {
  27. 35 //they didn't grant permissions
  28. 36 }
  29. 37 });
  30. 38 }
  31. 39 } else {
  32. 40 //later: display a lightbox telling them they've already submitted?
  33. 41 }
  34. 42 }, 'json');
  35. 43 });
  36. 44 }
  37. 45 });
  38. 46 }
  39. 47 </script>
Add Comment
Please, Sign In to add comment