I am facing a tricky problem with my code and hope to get some help on this. Below is a snippet of my code:
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.myurl.com/" data-text="My text" data-via="Via">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<script>
twttr.events.bind(
'tweet',
function (ev) {
<?php
$file = 'file.txt';
$id = trim($_GET["id"]);
$data = array("ID:$id", "CURRENT POSITION:$position", 'Twitter');
file_put_contents($file, implode(" ",$data).PHP_EOL,FILE_APPEND);
?>
}
);
</script>
I can't understand why my function (ev) triggers every time the page loads. It should be only triggered once a tweet has been posted. Anyone knows where the problem lies?
Aucun commentaire:
Enregistrer un commentaire