Published
Feb 28, 2010
|
In Random/Personal
I got introduced to Git and Gitbub by Yuvi and ever since I have been hooked up. I have started using it for all my pet projects. I even convinced Steve Bruner so that I can use Github for RoloPress.
Over the years I have released lot of code out in the wild and I thought of consolidating all of them in Github, so that it can be of use to someone who might need them. At last I found some time and uploaded most of them to my Gitbub account.
Below is the description of some of those projects which are currently there in my Github account.
Bright Light
Bright Light is the WordPress theme, which is powering up my blog. I have released it out hoping that it might be useful for someone.
Android Samples
I created this project to share my homework and the sample code used in the “Developing Android Applications in Java” online class, which I am currently following.
RoloPress core and RoloPress Default
These projects contain my contribution to RoloPress, a WordPress based contact manager. You can read more about WordPress from its homepage.
FeedBurner – stats
FeedBurner-stats is a Google Gadget which allows you to keep track of your Feedburner subscriber count. It uses Google Chart API and Google Gadget API.
Bloglines Notifier
Bloglines Notifier is a Google Gadget which will notify you the count of unread items in your Bloglines account. (Hope someone is still using Bloglines
)
Retweet
It is a fork of John Resig’s retweet script which I am using in my Easy Reweet WordPress Plugin. I have added a new feature to this script which allows you to associate the list of urls created to your bit.ly account.
Count Words
It’s a small Ruby script which prints the number of words (with their count) present in a given text file
Bulk unrar
It is a small Ruby script which unrars all files found in all the subdirectories of a director given in the command line.
I am still undecided about porting my WordPress Plugins from the official WordPress Plugin repository to Github. I guess it is better to have my Plugins in the Plugin repository for now.
BTW feel free to fork any of these projects and I would be happy to pull in your changes if you have added some enhancements to them.
Posted in Random/Personal
|
Tagged Bit.ly, git, github, Google Gadgets
|
Published
Aug 21, 2009
|
In API's/Mashup, Javascript/jQuery, WordPress
Recently while working on adding the feature to enter your own bit.ly API key to my Easy Retweet WordPress Plugin, I found out that by default all short urls created using bit.ly API (both REST and JavaScript API’s) are not associated with your account.
Upon further researching I found that there is an undocumented way of associating the urls created with your account. The undocumented way is to add an additional parameter called history with value 1 to the API URL.
Using the history parameter in bit.ly’s REST API
So for REST API, you have to use the following url.
http://api.bit.ly/shorten?version=2.0.1&longUrl=http://sudarmuthu.com&login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07&format=json&history=1
If you are using PHP, then code would be
function get_bitly_shorturl($longurl) {
$url = "http://api.bit.ly/shorten?version=2.0.1&login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07&format=json&history=1" . "&longurl=$longurl";
//using curl
$curlObject = curl_init();
curl_setopt($curlObject,CURLOPT_URL,$url);
curl_setopt($curlObject,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curlObject,CURLOPT_HEADER,false);
$result_json = curl_exec($curlObject);
curl_close($curlObject);
//decode JSON. Assumes that it is PHP5
$result = json_decode($result_json);
return $result['results'][shortUrl];
}
If you are going to use it in WordPress, then you can use the inbuilt WP_Http class instead of curl as suggested by Ozh. The following code shows you how it can be done in WordPress
function get_bitly_shorturl($longurl) {
$url = "http://api.bit.ly/shorten?version=2.0.1&login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07&format=json&history=1" . "&longurl=$longurl";
//using WP_Http present in WordPress
$request = new WP_Http;
$result_json = $request->request($url);
$result = json_decode($result_json);
return $result['results'][shortUrl];
}
Using the history parameter in bit.ly’s JavaScript API
If you are using bit.ly’s JavaScript API, then it is not as straight forward as the REST API. Instead of using the provided shorten method, you have to use the low level call method.
The following code shows you how you can do it in JavaScript API.
BitlyClient.call('shorten', {'longUrl':'http://sudarmuthu.com', 'history':'1'}, 'BitlyCB.shortenResponse');
I am not sure why bit.ly is not associating the created shorturls automatically with your account, when you provide the API Key, it is the expected default behavior. Or at least they could have documented about this history variable in their API. I guess only someone from bit.ly can answer this.
Posted in API's/Mashup, Javascript/jQuery, WordPress
|
Tagged API's/Webservices, Bit.ly, ozh, WordPress
|