Ads 468x60px

CSS

Thứ Tư, 27 tháng 6, 2012

Hiển thị số người follow Twitter, số fan Facebook và số người theo dõi RSS, 24 html


(24 htmlCái này thật ra thì có không có gì mới mẻ, đã có rất nhiều plugin làm việc này, nhưng hôm nay tôi sẽ hướng dẫn các bạn hiển thị những con số đó tại bất cứ đâu mà không cần dùng plugin


Twitter followers

Để hiển thị số người theo đuôi bạn trên Twitter bạn chỉ cần chèn đoạn code sau vào functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Get Twitter Follower Count - nino24_com //
function diww_twitter_followers ($twitter_user) {
 
     $url="http://twitter.com/users/show.xml?screen_name=". $twitter_user;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_URL, $url);
     $data = curl_exec($ch);
 
     curl_close($ch);
     $xml = new SimpleXMLElement($data);
     $tw_fol_count = $xml->followers_count;
     if ($tw_fol_count == false) { echo '512'; }
     else { echo number_format($tw_fol_count); }
 
}
Còn đây là đoạn code mà bạn sẽ đặt tại nơi muốn hiển thị:
1
 < ?php diww_twitter_followers ('nino24_com'); ?>
Thay nino24_com bằng tài khoản của bạn

Facebook Fans

Để hiển thị số fan trên fanpage của bạn, hãy chèn đoạn code sau vào functions.php:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 // Get Facebook Fan Count - http://nino24.com//
function diww_fb_fan_count($fb_id){
         $count = get_transient('fan_count');
    if ($count !== false) return $count;
         $count = 0;
         $data = wp_remote_get('http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id='.$fb_id.'');
   if (is_wp_error($data)) {
         return 'Error getting number';
   }else{
         $count = strip_tags($data[body]);
   }
set_transient('fan_count', $count, 60*60*24); // 24 hour cache
echo $count;
}
Chèn đoạn code sau vào nơi các bạn muốn hiển thị:
1
 < ?php diww_fb_fan_count ('154784051207520'); ?>
Trong đó 154784051207520 là id fanpage của bạn

RSS (FeedBurner) Subscribers

Để hiển thị số người theo dõi blog của bạn, hãy chèn code sau vào functions.php:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 // Get RSS Subscriber Count - www.itviet.vn//
function diww_fb_count ($fb_user) {
 
    $fburl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=". $fb_user;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $fburl);
    $stored = curl_exec($ch);
    curl_close($ch);
    $grid = new SimpleXMLElement($stored);
    $rsscount = $grid->feed->entry['circulation']+0;
    return number_format($rsscount);
 
}
 
function diww_fb_count_run($feed) {
 
    $fb_subs = diww_fb_count ($feed);
    $fb_option = "diww_fb_sub_value";
    $fb_subscount = get_option($fb_option);
    if (is_null($fb_subs)) { return $fb_subscount; }
    else {update_option($fb_option, $fb_subs); return $fb_subs;}
 
}
 
function diww_fb_sub_value($feed) {
 
    echo diww_fb_count_run($feed);
 
}
Chèn đoạn code sau vào nơi muốn hiển thị
1
 < ?php diww_fb_sub_value('nino24_com'); ?>
Trong đó itviet_vn là tên feed của bạn ví dụ: http://feeds.feedburner.com/BlogNino24

Nguồn:....................




Click vào nếu bài viết hữu ít hoặc hay đối với bạn ! thanks .^-^. (24html)


Tag : Tinh tức hay mỗi ngày , girl xinh 18+ , Thủ thuật facebook , chiến lượt Marketing hay , Kiến thức website , kiến thức CSS , trailer hay mỗi người

☆ Cùng tham gia cộng đồng chia sẽ tại Google Plus Anime24, Profile facebook , Page twitter ketban2424 với tớ nào

Không có nhận xét nào:

Đăng nhận xét