Lokalista
Shop now at www.lazada.com for low price items.

http://ho.lazada.com.ph/SHJ9gc?url=http%3A%2F%2Fwww.lazada.com.ph%2F%2F%3Foffer_id%3D%7Boffer_id%7D%26affiliate_id%3D%7Baffiliate_id%7D%26offer_name%3D%7Boffer_name%7D%26affiliate_name%3D%7Baffiliate_name%7D%26transaction_id%3D%7Btransaction_id%7D
Lokalista
Shop now at www.lazada.com for low price items.

http://ho.lazada.com.ph/SHJ9gc?url=http%3A%2F%2Fwww.lazada.com.ph%2F%2F%3Foffer_id%3D%7Boffer_id%7D%26affiliate_id%3D%7Baffiliate_id%7D%26offer_name%3D%7Boffer_name%7D%26affiliate_name%3D%7Baffiliate_name%7D%26transaction_id%3D%7Btransaction_id%7D
Lokalista
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Pinoy ideas and thoughts are unique co'z Pinoy rocks!!!

 
HomePortalSearchLatest imagesRegisterLog in

 

 How to Create Super Fast Retweet web 2.0 Widgets

Go down 
AuthorMessage
cyberbon
Anbu Assasin
Anbu Assasin
cyberbon


Male
Number of posts : 116
Age : 37
Registration date : 2008-12-07

How to Create Super Fast Retweet web 2.0 Widgets Empty
PostSubject: How to Create Super Fast Retweet web 2.0 Widgets   How to Create Super Fast Retweet web 2.0 Widgets Icon_minitimeMon Mar 15, 2010 9:36 am

How to Create Super Fast Retweet, Delicious and Facebook Share Widgets

Javascript based widgets can slow down your pages to a crawl. Not only they affect the overall page loading time, but sometimes also delay the loading of the real content, which is a major turnoff for your site’s visitors.

There are very good reasons why Javascript widgets are a cause of page slow-down.

1. Unoptimized code. Heavy usage of document.write function. Loading too many external scripts (javascript/css/images).
2. Slow server of widget host. The widget keeps loading and in the process blocks the more important content.

Today, I’ll show you how to create custom retweet, delicious save and facebook share widgets (with share / save count in plain text) using PHP, so your pages load with lightening fast speed.

Apart from the speed benefit, the HTML markup generated by my code is simple and can be styled with CSS the way you want it!.

Retweet widget (with topsy API)
This widget will use topsy otter API to generate a retweet widget. Example on the top right of this post (custom style).

Code:
<?php
   $shareUrl = urlencode(get_permalink($post->ID));
$shareTitle = urlencode($post->title);
$retweetNick = 'wpsplash';
$retweetInfo = json_decode(file_get_contents('http://otter.topsy.com/stats.json?url='.$shareUrl));
?>
<div class='retweet'>
    <a href='<?php echo $retweetInfo->response->topsy_trackback_url; ?>' class='count'>
        <span class='number'><?php echo $retweetInfo->response->all; ?></span>
        <span class='unit'>tweets</span>
    </a>
    <a href='http://button.topsy.com/retweet?nick=<?php echo $retweetNick; ?>&title=<?php echo $shareTitle; ?>&url=<?php echo $shareUrl; ?>' class='button'>Retweet</a>
</div>
1. shareURL: url of the page
2. shareTitle: title of the page which will be used as retweet text
3. retweetNick: twitter username that will appear in retweet message of the text

PHP5 requirement since it uses json_decode function.
Delicious Save Widget
This will generate a delicious widget as seen on the bottom of this post. You can however style it as per your choice with CSS.
Code:
<?php
   $shareUrl = urlencode(get_permalink($post->ID));
   $shareTitle = urlencode($post->title);
   $deliciousStats = json_decode(file_get_contents('http://feeds.delicious.com/v2/json/urlinfo/data?url='.$shareUrl));

?>
 
<a onclick='window.open("http://delicious.com/save?v=5&noui&jump=close&url=<?php echo $shareUrl; ?>&title=<?php echo $shareTitle; ?>", "facebook", "toolbar=no, width=550, height=550"); return false;' href='http://delicious.com/save?v=5&noui&jump=close&url=<?php echo $shareUrl; ?>&title=<?php echo $shareTitle; ?>' class='delicious'>
<?php
if($deliciousStats[0]->total_posts == 0) {
    echo 'Save';
} elseif($deliciousStats[0]->total_posts == 1) {
    echo 'One save';
} else {
    echo $deliciousStats[0]->total_posts.' saves';
}
?>
</a>
1. shareURL: url of the page
2. shareTitle: title of the page

PHP5 requirement since it uses json_decode function.

Facebook Share Widget
This will generate facebook share widget as seen on the bottom right of this post. Like delicious widget, you can style it with CSS.
Code:
<?php
   $shareUrl = urlencode(get_permalink($post->ID));
   $shareTitle = urlencode($post->title);
   $fbLinkStats = simplexml_load_file('http://api.facebook.com/restserver.php?method=links.getStats&urls='.$shareUrl);

?>
 
<a onclick='window.open("http://www.facebook.com/sharer.php?u=<?php echo $shareUrl; ?>&t=<?php echo $shareTitle; ?>", "facebook", "toolbar=no, width=550, height=550"); return false;' href='http://www.facebook.com/sharer.php?u=<?php echo $shareUrl; ?>&t=<?php echo $shareTitle; ?>'  class='facebookShare'>
 
<?php
if($fbLinkStats->link_stat->total_count == 0) {
    echo 'Share';
} elseif($fbLinkStats->link_stat->total_count == 1) {
    echo 'One share';
} else {
    echo $fbLinkStats->link_stat->total_count.' shares';
}
?>
</a>

1. shareURL: url of the page
2. shareTitle: title of the page

PHP5 requirement since it uses simplexml library.

This is it! You got customizable Retweet, Delicious, and Facebook share widgets with share count and all, that do not slow down your page

What icon pack are you using on WPSplash?

We are using Social Media Netework Icons Pack by Komodo Media. They are beautiful!
http://www.komodomedia.com/blog/2009/06/social-network-icon-pack/
How do I optimize X widget?
se the API offered by the widget’s site with your favourite server-side language, PHP in case you’re using WordPress. Also, post your requests in comments. We’ll make updates to this post and send status updates via twitter. Follow WPSplash on Twitter, and subscribe to RSS feed.
http://twitter.com/WPSplash

http://www.feedburner.com/
Back to top Go down
http://www.cyberbon.com
 
How to Create Super Fast Retweet web 2.0 Widgets
Back to top 
Page 1 of 1
 Similar topics
-
» How to Create Anagrams
» 15 web based application to create Mock-ups & Wireframes
» Super Screen Capture
» Super Internet TV Satellite 2008 v2.1 + Crack
» MEGA ULTA SUPER YOUTH CAMP (kabacan)

Permissions in this forum:You cannot reply to topics in this forum
Lokalista :: ComTech section :: Website-
Jump to: