Allora, ti spiego cosa ho fatto:
ho inserito questo subito dopo il tag <body>
Poi dove mi interessava mettere il bottone ho aggiuntocodice:<div id="fb-root"></div> <script> window.fbAsyncInit =function(){ // init the FB JS SDK FB.init({ appId :'MIO_APP_ID',// App ID from the app dashboard status :true,// Check Facebook Login status xfbml :true// Look for social plugins on the page }); // Additional initialization code such as adding Event Listeners goes here }; // Load the SDK asynchronously (function(){ // If we've already installed the SDK, we're done if(document.getElementById('facebook-jssdk')){return;} // Get the first script element, which we'll use to find the parent node var firstScriptElement = document.getElementsByTagName('script')[0]; // Create a new script element and set its id var facebookJS = document.createElement('script'); facebookJS.id ='facebook-jssdk'; // Set the new script's source to the source of the Facebook JS SDK facebookJS.src ='//connect.facebook.net/it_IT/all.js'; // Insert the Facebook JS SDK into the DOM firstScriptElement.parentNode.insertBefore(facebookJS, firstScriptElement); }()); </script>
E nel file clickSulLike.php ho messocodice:<fb:like href="http://www.sito.it"></fb:like> <script> FB.Event.subscribe('edge.create',function(href, widget) { $.ajax({ type:"POST", url:"clickSuLike.php", data:{'Utente':'Nome Cognome'}, }); }); </script>
Il bottone si vede, ci clicco su e si apre una tendina che mi dice di pubblicare (che a me non serve, ma non è un grosso problema), in ogni caso:codice:<? require './files/config.php'; require './files/functions.php'; mysql_query("UPDATE utente SET rep=rep+10 WHERE username='$_SESSION[valid_user]'") or die(mysql_error()); ?>
premo su pubblica e non succede niente;
la rep nel db non viene aumentata;
se provo a togliere il like non succede niente;
se aggiorno la pagina è come se non avessi messo like.

Rispondi quotando