Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <style type="text/css">
- .data{
- color: black;
- background-color: grey;
- padding-top: 5px;
- padding-bottom: 5px;
- }
- .content{
- }
- </style>
- </head>
- <body>
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <div id="fb-root"></div>
- <div class="refreshButton"></div><div class="content" id="content"></div>
- <script>
- /*
- FB Api initialization
- */
- window.fbAsyncInit = function() {
- FB.init({
- appId : '211096316065594',
- xfbml : true,
- version : 'v2.9'
- });
- FB.AppEvents.logPageView();
- };
- /*
- Loading SDK.
- */
- (function(d, s, id){
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) {return;}
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/en_US/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- (function(d){
- var js, id ='facebook-jssdk', ref = d.getElementsByTagName('script')[0];
- if(d.getElementById(id)){return;}
- js = d.createElement('script'); js.id = id; js.async =true;
- js.src ="//connect.facebook.net/fr_FR/all.js";
- ref.parentNode.insertBefore(js, ref);
- }(document));
- function fbLogin() {
- /*
- Login to autorized account.
- The owner of the module is "Wistaro Tiplanet" account.
- */
- $('.bco').hide();
- 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
- function printFeed(){
- //setTimeout(printFeed,5000); //autoreload function. Disabled here.
- $('.refreshButton').html('<button onclick="printFeed()">Rafraichir</button>');
- $('.content').empty(); //cleaning div
- FB.api(
- "/478661852332525/feed?since=&until=&limit=50", //since and until arguments are useful to load posts on a specific period.
- function (response) {
- if (response && !response.error) {
- console.log(response.data);
- for (var i =0; i < 50 ; i++) {
- var contentStr = response.data[i].message;
- $('.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>');
- }
- }else{
- alert('Vous devez être connecté!');
- }
- }
- );
- }
- function exportBB(contentData){
- alert(acontentData);
- }
- function sendMessageOnGroup(message){
- /*
- This function DOESNT WORK because of insufficient permissions with Fb API !!
- */
- FB.api(
- "/478661852332525/feed",
- "POST",
- {
- "message": message
- },
- function (response) {
- if (response && !response.error) {
- alert('Message envoyé');
- }else{
- alert('erreur!'+response.error.toString());
- console.log(response.error);
- }
- }
- );
- }
- function deco() {
- /*
- Disconnect the current FB session.
- */
- FB.getLoginStatus(function(response) {
- if (response && response.status === 'connected') {
- FB.logout(function(response) {
- document.location.reload();
- });
- }
- });
- }
- </script>
- <button onclick="fbLogin()" class="bco">(1) Connexion</button>
- <button onclick="printFeed()" class="bprint">(2) Afficher publications</button>
- <button onclick="sendMessageOnGroup('toto')" class="bsend">(3) Envoyer un message</button>
- <button onclick="deco()" class="bdeco">(4) Déconnextion</button>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement