Display Facebook likes / Shares PHP function

PHP, PHP Scripts, Techniques
The CodeBelow is a super simple function that retrieves a JSON feed of comments, likes and shares for any URL you provide. function facebook_shares($url){ $fql = "SELECT url, normalized_url, share_count, like_count, comment_count, "; $fql .= "total_count, commentsbox_count, comments_fbid, click_count FROM "; $fql .= "link_stat WHERE url = '".$url."'"; $apifql="https://api.facebook.com/method/fql.query?format=json&query=".urlencode($fql); $fb_json=file_get_contents($apifql); return json_decode($fb_json); } How to use $fb = facebook_shares('https://www.facebook.com/redbull'); // facebook share count echo $fb[0]->share_count; // facebook like count echo $fb[0]->like_count; // facebook comment count echo $fb[0]->comment_count;
Read More

Show Google Plus’s – PHP function

PHP, PHP Scripts, Techniques
To get prefers and impart information for a Url here's a capacity to get Google Plus' for any Url. The Code It’s worth pointing out you must have CURL enabled on your web server, I believe it’s enabled by default on PHP5 setups. Also the Key below Isn’t a unique API key you must leave the key as is to ensure the code works properly. function gplus_shares($url){ // G+ DATA $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p", "params":{"nolog":true,"id":"' . $url . '","source":"widget","userId":"@viewer","groupId":"@self"}, "jsonrpc":"2.0","key":"p","apiVersion":"v1"}]'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); $result = curl_exec ($ch); curl_close ($ch); return json_decode($result, true); } Example Usage $gplus = gplus_shares('https://facebook.com'); echo $gplus[0]['result']['metadata']['globalCounts']['count'];
Read More

Automatic jQuery site subscription lightbox

Ajax, Tutorials, Web Design & Programming
Getting Started You’ll need to include the jQuery library as well as the Colorbox lightbox JS and CSS which are included in the download below. <!-- Color Box CSS --> <link media="screen" rel="stylesheet" target="_blank" href="css/colorbox.css" /> <!-- Style For the Subscription Box --> <link media="screen" rel="stylesheet" target="_blank" href="css/popup.css" /> http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js http://js/colorbox.js The JS Code Once the page loads we check to see if the cookie exists and hasn’t expired. If it’s expired or doesn’t exist we set the cookie to expire in 15 days, and we show the lightbox. $("document").ready(function (){ // load the overlay if (document.cookie.indexOf('visited=true') == -1) { var fifteenDays = 1000*60*60*24*15; var expires = new Date((new Date()).valueOf() + fifteenDays); document.cookie = "visited=true;expires=" + expires.toUTCString(); $.colorbox({width:"580px", inline:true, href:"#subscribe_popup"}); } $(".open_popup").colorbox({width:"580px", inline:true, href:"#subscribe_popup"}); }); The HTML Here’s the HTML…
Read More

Simple MySQL database access wrapper

Databases, PHP, Tutorials
This class is a basic Mysql database access wrapper. It can: -Establish an association with a given Mysql server host -Execute Sql questions -Retrieve question comes about into exhibits -Retrieve the outcome set number of columns, final embedded identifier or the amount of influenced columns -Check if a database table record exists matching a given condition -Retrieve the amount of records that a table has matching a given condition Below is class: class.php: <?php class WGDB{ public $connection ; public $querycount = 0; public function db() {} public function connect($dbhost, $dbusername, $dbpassword) { $this->connection = mysql_connect($dbhost,$dbusername,$dbpassword); return $this->connection; } public function close() { return mysql_close( $this->connection ); } public function select_db($databasename) { return mysql_select_db($databasename,$this->connection); } public function exist($tablename, $fieldname, $value, $where = false) { $exist = $this->fastfetch("select * from `$tablename` where `$fieldname` = '$value' ".check($where, " $where").""); return check($exist['id'], true, false); } public function count($tablename, $where = false) { $query = $this->query("select * from `$tablename` ".check($where, "where $where").""); return $this->fetchnum($query); } public function query($sql) { $this->querycount++; return mysql_query($sql,$this->connection); } public function fastfetch($sqlcode, $type = MYSQL_BOTH ) { $query = $this->query($sqlcode) ; return $this->fetcharray($query, $type); } public function fetcharray($query, $type = MYSQL_BOTH ) { return mysql_fetch_array($query, $type); } public function fetchassoc($query) { return mysql_fetch_assoc($query); } public function fetchnum($query) { return mysql_num_rows($query); } public function fetchobject($query) { return mysql_fetch_object($query); } public function escape($string) { return mysql_escape_string($string);…
Read More

Validation with jQuery

Ajax, Tutorials
This time I need to clarify about "Form acceptance utilizing standard outflows with jquery". I had advanced an excercise utilizing jquery.validate plugin, It's extremely straightforward. Actualize this and improve your web tasks. http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js http://jquery.validate.js $(document).ready(function() { $.validator.addMethod("email", function(value, element) { return this.optional(element) || /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+.[a-zA-Z.]{2,5}$/i.test(value); }, "Please enter a valid email address."); $.validator.addMethod("username",function(value,element) { return this.optional(element) || /^[a-zA-Z0-9._-]{3,16}$/i.test(value); },"Username are 3-15 characters"); $.validator.addMethod("password",function(value,element) { return this.optional(element) || /^[A-Za-z0-9!@#$%^&*()_]{6,16}$/i.test(value); },"Passwords are 6-16 characters"); // Validate signup form $("#signup").validate({ rules: { email: "required email", username: "required username", password: "required password", }, }); }); Download Script
Read More

File browser with ajax

Ajax, PHP
This class can used to maintain indexes on the server side utilizing an Ajax based client interface to maintain a strategic distance from page reloading. It produce a client interface to perform numerous sorts of operations on server side records perusing envelopes, erase, duplicate, glue, cut, and make new index or envelope. Download file
Read More

Edit Table in Ajax

Ajax, PHP, PHP Scripts
This class might be utilized to alter information in the cells of a Html table utilizing Ajax to safeguard the adapted unit values without reloading the present page. It takes a bi-dimensional cluster as parameter to describe the substance of the units of the table to be altered. At that point it creates the table Html with the indispensible Javascript code to alter the unit substance. The client may alter the units by clicking on them. The unit is transformed into a content information so the client can modify the unit substance with the console. In the event that you are utilizing Advate then you can detail the sort of info you need returned: content, textarea, select, radio, and checkboxes. For the last three, you have the capacity to define…
Read More

AJAX Rating Counter

Ajax, PHP, PHP Scripts
This bundle might be utilized to actualize a star rating framework that uses Ajax to overhaul the normal rate without reloading the rate page after a client has voted. It can show the present normal rating between 1 to 10 utilizing star symbol pictures. Another rating submitted by a client is sent to the server utilizing an Ajax solicitation. The server gives back where its due rating normal and the star symbol pictures change to the new rating worth. Download file from here
Read More