Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- code pase functions.php
- $facebook_like_share_count = function ( $url ) {
- $api = file_get_contents( 'http://graph.facebook.com/?id=' . $url );
- $count = json_decode( $api );
- return $count->shares;
- };
- $twitter_tweet_count = function ( $url ) {
- $api = file_get_contents( 'https://cdn.api.twitter.com/1/urls/count.json?url=' . $url );
- $count = json_decode( $api );
- return $count->count;
- };
- $pinterest_pins = function ( $url ) {
- $api = file_get_contents( 'http://api.pinterest.com/v1/urls/count.json?callback%20&url=' . $url );
- $body = preg_replace( '/^receiveCount\((.*)\)$/', '\\1', $api );
- $count = json_decode( $body );
- return $count->count;
- };
- $google_plusones = function ( $url ) {
- $curl = curl_init();
- curl_setopt( $curl, CURLOPT_URL, "https://clients6.google.com/rpc" );
- curl_setopt( $curl, CURLOPT_POST, 1 );
- curl_setopt( $curl, 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( $curl, CURLOPT_RETURNTRANSFER, true );
- curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Content-type: application/json' ) );
- $curl_results = curl_exec( $curl );
- curl_close( $curl );
- $json = json_decode( $curl_results, true );
- return intval( $json[0]['result']['metadata']['globalCounts']['count'] );
- };
- show file....
- $url = get_permalink( $post_id ) echo $facebook_like_share_count ("$url") ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement