Advertisement
Wistaro

ece_js_generator_wistaro

May 28th, 2017
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.87 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <style type="text/css">
  4.         .data{
  5.  
  6.             color: black;
  7.             background-color: grey;
  8.             padding-top: 5px;
  9.             padding-bottom: 5px;
  10.                
  11.         }
  12.         .content{
  13.  
  14.         }
  15.     </style>
  16.  
  17. </head>
  18. <body>
  19. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  20. <div id="fb-root"></div>
  21.  
  22. <div class="refreshButton"></div><div class="content" id="content"></div>
  23. <script>
  24.  
  25.     /*
  26.     FB Api initialization
  27.     */
  28.     window.fbAsyncInit = function() {
  29.     FB.init({
  30.       appId      : '211096316065594',
  31.       xfbml      : true,
  32.       version    : 'v2.9'
  33.     });
  34.     FB.AppEvents.logPageView();
  35.   };
  36.  
  37.   /*
  38.     Loading SDK.
  39.   */
  40.   (function(d, s, id){
  41.      var js, fjs = d.getElementsByTagName(s)[0];
  42.      if (d.getElementById(id)) {return;}
  43.      js = d.createElement(s); js.id = id;
  44.      js.src = "//connect.facebook.net/en_US/sdk.js";
  45.      fjs.parentNode.insertBefore(js, fjs);
  46.    }(document, 'script', 'facebook-jssdk'));
  47.    
  48.  
  49.     (function(d){
  50.         var js, id ='facebook-jssdk', ref = d.getElementsByTagName('script')[0];
  51.         if(d.getElementById(id)){return;}
  52.         js = d.createElement('script'); js.id = id; js.async =true;
  53.         js.src ="//connect.facebook.net/fr_FR/all.js";
  54.         ref.parentNode.insertBefore(js, ref);
  55.     }(document));
  56.    
  57.    
  58.     function fbLogin() {
  59.  
  60.         /*
  61.         Login to autorized account.
  62.         The owner of the module is "Wistaro Tiplanet" account.
  63.    
  64.         */
  65.         $('.bco').hide();
  66.         FB.login(function(){}, { scope: 'user_managed_groups, user_birthday, user_location',return_scopes: true });} //some permissions are useless for our script, it's just for tests
  67.  
  68.     function printFeed(){
  69.  
  70.         //setTimeout(printFeed,5000); //autoreload function. Disabled here.
  71.  
  72.         $('.refreshButton').html('<button onclick="printFeed()">Rafraichir</button>'); 
  73.  
  74.             $('.content').empty(); //cleaning div
  75.                        
  76.         FB.api(
  77.                 "/478661852332525/feed?since=&until=&limit=50", //since and until arguments are useful to load posts on a specific period.
  78.                 function (response) {
  79.                   if (response && !response.error) {
  80.  
  81.                     console.log(response.data);
  82.                    for (var i =0; i < 50 ; i++) {
  83.  
  84.                     var contentStr = response.data[i].message;
  85.                    
  86.                         $('.content').append('<div class="data"><hr><div>#'+i+'</div>'+contentStr+'<div class="link"><a href="https://www.facebook.com/groups/ECEBac2017/permalink/'+(response.data[i].id.toString()).substring(16,32)+'">Lien direct</a> <div class="createUI"> <button onclick="exportBB('+contentStr+')">Export BBCode</button></div></div></div>');
  87.  
  88.                       }
  89.  
  90.                   }else{
  91.  
  92.                     alert('Vous devez être connecté!');
  93.  
  94.                   }
  95.                 }
  96.         );
  97.    
  98.     }
  99.  
  100.     function exportBB(contentData){
  101.  
  102.  
  103.         alert(acontentData);
  104.     }
  105.  
  106.     function sendMessageOnGroup(message){
  107.  
  108.         /*
  109.             This function DOESNT WORK because of insufficient permissions with Fb API !!
  110.  
  111.         */
  112.         FB.api(
  113.             "/478661852332525/feed",
  114.             "POST",
  115.             {
  116.                 "message": message
  117.             },
  118.             function (response) {
  119.               if (response && !response.error) {
  120.                 alert('Message envoyé');
  121.               }else{
  122.  
  123.                 alert('erreur!'+response.error.toString());
  124.                 console.log(response.error);
  125.  
  126.               }
  127.             }
  128.         );
  129.  
  130.  
  131.  
  132.     }
  133.  
  134.      function deco() {
  135.         /*
  136.            
  137.             Disconnect the current FB session.
  138.    
  139.         */
  140.     FB.getLoginStatus(function(response) {
  141.         if (response && response.status === 'connected') {
  142.            FB.logout(function(response) {
  143.                document.location.reload();
  144.             });
  145.         }
  146.     });
  147. }
  148.  
  149.  
  150.  
  151.     </script>
  152.    
  153.  
  154.     <button onclick="fbLogin()" class="bco">(1) Connexion</button>
  155.     <button onclick="printFeed()" class="bprint">(2) Afficher publications</button>
  156.     <button onclick="sendMessageOnGroup('toto')" class="bsend">(3) Envoyer un message</button>
  157.     <button onclick="deco()" class="bdeco">(4) Déconnextion</button>
  158.  
  159.      
  160.  
  161.  
  162. </body>
  163.  
  164. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement