Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. var risp;
  2. var string = "";
  3. var stringOth = "";
  4. var objectID;
  5. var pageAccessToken;
  6. var rispostaPerToken;
  7. var stringinterno = "";
  8. var i;
  9.  
  10. function statusChangeCallback(response) {
  11. console.log('statusChangeCallback');
  12. console.log(response);
  13. // The response object is returned with a status field that lets the
  14. // app know the current login status of the person.
  15. // Full docs on the response object can be found in the documentation
  16. // for FB.getLoginStatus().
  17. if (response.status === 'connected') {
  18. // Logged into your app and Facebook.
  19. prova();
  20. } else if (response.status === 'not_authorized') {
  21. // The person is logged into Facebook, but not your app.
  22. document.getElementById('status').innerHTML = "Si prega di effettuare il Login all'applcazione";
  23. } else {
  24. // The person is not logged into Facebook, so we're not sure if
  25. // they are logged into this app or not.
  26. document.getElementById('status').innerHTML = 'Per visualizzare la galleria effettuare Login a Facebook.';
  27. }
  28. };
  29. function checkLoginState() {
  30. FB.getLoginStatus(function(response) {
  31. statusChangeCallback(response);
  32. });
  33. }
  34. function prova(){
  35. FB.api(
  36. '/422454964453085/feed', {
  37. access_token : pageAccessToken
  38. },
  39. function (risp){
  40. var count=0;
  41. var link ="";
  42. //risp = response;
  43. for (i = 0; i < risp.data.length; i++){
  44. if (risp.data[i].type == "photo"){
  45. objectID = risp.data[i].object_id;
  46. obtainPic(objectID, i);
  47.  
  48. }
  49. }
  50.  
  51. $("#galleria").html(string);
  52. }
  53. )
  54. };
  55.  
  56.  
  57. function obtainPic(dato, i) {
  58. FB.api(
  59. '/' + dato, {
  60. access_token : pageAccessToken
  61. }, function (rispDue){
  62. link= rispDue.images[3].source;
  63. linkGrande = rispDue.images[0].source;
  64. if (rispDue.data[0].description == undefined){
  65. if (rispDue.data[0].message == undefined){
  66. stringinterno +="<div class='thumbnail col-sm-6 col-md-4 col-lg-4'><img class='imag' src='" + link + "'><div class='caption'><h3>" + rispDue.data[0].from.name + "</h3><p>" + rispDue.data[0].story + "</p></div></div>";
  67. } else {
  68. stringinterno +="<div class='thumbnail col-sm-6 col-md-4 col-lg-4'><img class='imag' src='" + link + "'><div class='caption'><h3>" + rispDue.data[0].from.name + "</h3><p>" + rispDue.data[0].message + "</p></div></div>";
  69. }
  70. } else {
  71. stringinterno +="<div class='thumbnail col-sm-6 col-md-4 col-lg-4'><img class='imag' src='" + link + "'><div class='caption'><h3>" + rispDue.data[0].from.name + "</h3><p>" + rispDue.data[0].description + "</p></div></div>";
  72. }
  73. }
  74. )
  75. }
  76.  
  77. window.fbAsyncInit = function() {
  78.  
  79.  
  80. FB.init({
  81. appId : '866225023436362',
  82. cookie : true,
  83. xfbml : true,
  84. version : 'v2.3'
  85. });
  86.  
  87. FB.getLoginStatus(function(response) {
  88. pageAccessToken = response.authResponse.accessToken;
  89. statusChangeCallback(response);
  90. });
  91.  
  92. };
  93.  
  94.  
  95.  
  96. (function(d, s, id) {
  97. var js, fjs = d.getElementsByTagName(s)[0];
  98. if (d.getElementById(id)) return;
  99. js = d.createElement(s); js.id = id;
  100. js.src = "http://connect.facebook.net/it_IT/sdk.js#xfbml=1&version=v2.3&appId=871644672893047";
  101. fjs.parentNode.insertBefore(js, fjs);
  102. }(document, 'script', 'facebook-jssdk'));
  103.  
  104. function testAPI() {
  105. console.log('Welcome! Fetching your information.... ');
  106. FB.api('/me', function(response) {
  107. console.log('Successful login for: ' + response.name);
  108. document.getElementById('status').innerHTML =
  109. 'Thanks for logging in, ' + response.name + '!';
  110. });
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement