How to store Facebook shares in database using JSON?

by 7 replies
9
I want to store Facebook shares of my website in the MySQL database. I used following code to get the share value when page load. But I don't know how to save it into database?
Code:
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script> 
        $x='http://api.facebook.com/method/links.getStats?urls=http://www.yahoo.com&format=json'; 
$.ajax({   
       url: 'http://api.facebook.com/method/links.getStats?urls=http://www.yahoo.com&format=json',  
      success: function(data){     
      $("#dd").html(data[0]['comment_count']);   
} });
</script>
In the body section I use div to show this value

HTML Code:
Comment count = <div id="dd"></div>
#programming #database #facebook #json #shares #store
  • I'm not sure why, but I'm not able to post my code here, so full post I've written here you will find on: http://pastebin.com/pidKQ66p
    • [ 1 ] Thanks
    • [2] replies
    • Geeksoftware is right, your javascript is fine but the main thing is to have a script to handle the sql insert.

      If you plan on working with a lot of data I would suggest building a controller, or using a PHP framework like laravel.
    • Thank you for your help geekSoftware but I still cant store the values in my database. I check database connection and its working, but I still cant store the values...
      • [1] reply
  • It was my mistake...
    Its working great...
    Thank you geeksoftware
    • [1] reply

Next Topics on Trending Feed

  • 9

    I want to store Facebook shares of my website in the MySQL database. I used following code to get the share value when page load. But I don't know how to save it into database? Code: <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $x='http://api.facebook.com/method/links.getStats?urls=http://www.yahoo.com&format=json'; $.ajax({ url: 'http://api.facebook.com/method/links.getStats?urls=http://www.yahoo.com&format=json', success: function(data){ $("#dd").html(data[0]['comment_count']); } }); </script> In the body section I use div to show this value