Plugin Directory

Changeset 415823


Ignore:
Timestamp:
07/27/2011 07:54:42 AM (15 years ago)
Author:
mortay
Message:

Modificación urgente por el contador de Facebook, además se ha incluido una modificación del contador para Twitter.

Location:
social-counters/trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • social-counters/trunk/counters/facebook.php

    r391639 r415823  
    4646                $post_url = urlencode($post_url);
    4747               
    48                 $url_request = 'http://api.facebook.com/restserver.php?format=json&method=links.getStats&urls={url}';
     48                //$url_request = 'http://api.facebook.com/restserver.php?format=json&method=links.getStats&urls={url}';
     49                $url_request = 'http://graph.facebook.com/?id={url}';
    4950                $url_request = str_replace('{url}', $post_url, $url_request);
    5051               
     
    5354                if ( !empty($data) ) {
    5455                    $data = json_decode($data);
    55                     if ( sizeof($data) == 1 ) {
    56                         $shared_counter = $data[0]->total_count;
    57                     }
     56                    if ( isset($data->shares) )
     57                        $shared_counter = $data->shares;
    5858                }
    5959            }
  • social-counters/trunk/counters/twitter.php

    r391639 r415823  
    3636        $share_counter_meta = get_post_meta($_post->ID, '_shared_counter_twitter_v2', true);
    3737       
    38         if ( !is_single() && $share_counter_meta !== false ) {
     38        if ( !is_single() && !empty($share_counter_meta) && $share_counter_meta !== false ) {
    3939           
    4040            $shared_counter = $share_counter_meta;
     
    4646           
    4747            // Search in TWEETMEME
    48             $url_request_params = '?url={url}';
    49             $url_request_params = str_replace('{url}', $post_url, $url_request_params);
    50            
    51             $url_request = 'http://api.tweetmeme.com/url_info.php';
    52             $url_request .= $url_request_params;
    53             $data = wp_remote_retrieve_body(wp_remote_get($url_request));
    54            
    55             $url_request_params = '';
    56             if ( !empty($data) ) {
    57                 $data = unserialize($data);
    58                    
    59                 if ( isset($data['status']) && $data['status'] == 'failure' ) {
    60                     $shared_counter = '<em title="'. $data['comment'] .'">0</em>';
    61                 }else{
    62                     $shared_counter = $data['story']['url_count'];
    63                 }
    64             }
     48            // $shared_counter = social_counters__twitter__tweetmeme($post_url, $shared_counter);
     49            // Search in TWITTER
     50            $shared_counter = social_counters__twitter__twitter($post_url, $shared_counter);
    6551           
    6652            if ( $share_counter_meta ) {
     
    128114}
    129115add_action('social_counter__wp_head', 'social_counter__wp_head__twitter');
     116
     117
     118
     119
     120// Twitter Counter Systems!!
     121
     122function social_counters__twitter__tweetmeme( $post_url = '', $shared_counter = 0 ) {
     123   
     124    if ( !empty($post_url) ) {
     125       
     126        $url_request_params = '?url={url}';
     127        $url_request_params = str_replace('{url}', $post_url, $url_request_params);
     128       
     129        $url_request = 'http://api.tweetmeme.com/url_info.php';
     130        $url_request .= $url_request_params;
     131       
     132        $data = wp_remote_retrieve_body(wp_remote_get($url_request));
     133       
     134        $url_request_params = '';
     135        if ( !empty($data) ) {
     136            $data = unserialize($data);
     137               
     138            if ( isset($data['status']) && $data['status'] == 'failure' ) {
     139                $shared_counter = '<em title="'. $data['comment'] .'">0</em>';
     140            }else{
     141                $shared_counter = $data['story']['url_count'];
     142            }
     143        }
     144       
     145    }
     146   
     147    return $shared_counter;
     148}
     149
     150function social_counters__twitter__twitter( $post_url = '', $shared_counter = 0 ) {
     151   
     152    if ( !empty($post_url) ) {
     153       
     154        $url_request_params = '?url={url}';
     155        $url_request_params = str_replace('{url}', $post_url, $url_request_params);
     156       
     157        $url_request = 'http://urls.api.twitter.com/1/urls/count.json';
     158        $url_request .= $url_request_params;
     159       
     160        $data = wp_remote_retrieve_body(wp_remote_get($url_request));
     161       
     162        $url_request_params = '';
     163        if ( !empty($data) ) {
     164            $data = unserialize($data);
     165               
     166            if ( isset($data['count']) )
     167                $shared_counter = $data['count'];
     168        }
     169       
     170    }
     171   
     172    return $shared_counter;
     173}
  • social-counters/trunk/readme.txt

    r391639 r415823  
    44Requires at least: 2.9
    55Tested up to: 3.1.2
    6 Stable tag: 2.1.0
     6Stable tag: 2.1.1
    77
    88It allows to place social sharing links with counters (if available) to the most popular social networks: Menéame,Twitter,Facebook,...
     
    5252== Changelog ==
    5353
     54= 2.1.1 =
     55* Changed counter system on Twitter, now used Twitter itself, not Tweetmeme
     56* Fixed Facebook counter, now uses the Graph API.
     57
    5458= 2.1.0 =
    5559* Added param to send post object to functions "the_" (postparam).
  • social-counters/trunk/social-counters.php

    r391639 r415823  
    44Plugin URI: http://blogestudio.com/plugin/social-counters/
    55Description:  Get Counters from Social Webs
    6 Version: 2.1.0
     6Version: 2.1.1
    77Author: Alejandro Carravedo (Blogestudio)
    88Author URI: http://blogestudio.com
     9
    910
    10111.1.0   - Solucionado error con la cache de contador
     
    21222.1.0   - Anadido parametro para enviar el objecto POST a las funciones "the_" (postparam).
    2223        - Cambiado sistema de "share" en Twitter
     24       
     252.1.1   - Cambiado sistema de contador en Twitter, ahora se usa el propio Twitter, no TweetMeMe
     26        - Reparado contador de Facebook, ahora funciona con el Graph API, han quitado de sopetón los datos del REST API.
     27
    2328       
    2429*** Configuraciones ***
     
    6267require_once('counters/twitter.php');
    6368require_once('counters/facebook.php');
     69//require_once('counters/bitacoras.php');
    6470
    6571
Note: See TracChangeset for help on using the changeset viewer.