I am currently in Yahoo’s 5th Open hackday, which is happening in Bangalore and just finished my talk about using Flickr API for your hacks.
Category Archives: API’s/Mashup
Code sample to access YQL from PHP
Just wrote quick some code sample to show how to access YQL (Yahoo Query Language) queries from PHP.
You can use the following code sample to fetch results from YQL from any standard PHP file. You would require the curl extension to be installed. If you are behind a proxy, uncomment the 3 lines and replace it with proper proxy values
If you have the Yahoo social SDK installed and you want to access results from YQL, then you can use the following code sample. Replace the text consumer_key and consumer_secret with correct values.
Update: You can also get code snippets for other languages apart from PHP.
Posted in API's/Mashup, Web Programming Tagged API's/Webservices, PHP, YQL 2 Comments
Associating urls created with bit.ly API to your account
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, WordPress 8 Comments
Updated FeedBurner stats Google Gadget
I have updated my FeedBurner stats Google Gadget, to change the API endpoint to feedburner.google.com. If you have already added the gadget to iGoogle or have embedded it in your web pages, the changes will apply automatically and you donโt need to change anything.
The Gadget ceased to work after Google changed the API endpoint and it should continue to work after this change.
The full source code of this gadget is available here and if you are interested you can add it to your Google personalised page by clicking this button.
Let me know if you still face any issues with the Gadget.
Posted in API's/Mashup Tagged FeedBurner, Google Gadgets, stats 2 Comments
oAuth support in Twitter and WordPress 2.8
After waiting for more than two years, Twitter has finally enabled support for oAuth to all developers using its API. Itโs a great move and itโs a win-win situation both for the developers and also for Twitter users. Going forward, the Twitter third-party developers need not ask Twitter users for their username and password.
For the uninitiated, oAuth is an open protocol for online authentication. It enables a user who stores information such as a password on a particular Web site to then authorize yet another site to access that data, all the while not sharing the user’s identity with that site.
To give you a real-world non-technical example, it is like a car valet key, given to a parking assistant. Valet key unlike the original key, will have lot of restrictions like you cannot drive beyond few kilometers or cannot go beyond a particular speed etc.
In a similar move, WordPress 2.8 will also enable support for oAuth. Will Norris, has published an article explaining how oAuth is planned to be implemented in WordPress 2.8. There are yet some limitations (oAuth libraries need PHP5) but itโs a great start.
If you are a WordPress Plugin author of any Plugin that hooks into authentication then you may have to change your Plugin code to support oAuth.
I am really excited about the support for oAuth in Twitter and WordPress. I need to play with them a little once I get some free time. ๐
Posted in API's/Mashup, WordPress Tagged oAuth, Twitter, WordPress 4 Comments
Google Gadget to keep track of your FeedBurner stats
I had some free time this weekend and I used it to create my second Google Gadget called called FeedBurner stats. (By the way my first gadget was Bloglines Notifier, which notifies the count of unread items in your Bloglines account). It uses FeedBurner Awareness API to fetch the subscriber count of your FeedBurner feed and displays it using Google Charts API.
The full source code of this gadget is available here and if you are interested you can add it to your Google personalised page by clicking this button.
After you add the gadget, you just need to enter your FeedBurner feed URL. The gadget will fetch the subscriber count for the past one week and will display it in a nice bar graph using Google Charts API.
API’s used
The following are the API’s used for creating this gadget
Posted in API's/Mashup Tagged FeedBurner, Google Charts, Google Gadgets, stats 10 Comments
Year End Stats for 2007 (Graphs)
When I published my year end stats, little did I know that numbers alone doesn’t matter much, unless they are presented in an easily-to understand manner.
So here I am representing the same numbers but in a much more understandable manner, with some support from the excellent Google Chart API, which I learned during pipesCamp.
Number of posts
You could see that the number of posts has almost dropped by 40% in 2007. There were 64 posts in 2006 where as only 38 in 2007. One reason for this is that lot of unexpected things happened in my personal life which took me away from the computer and the other reason is that I got busy and free time became a rare commodity for me. So this is an area where I should improve.
Number of comments
Again, as with the number of posts, the number of comments was also less by around 40%. There were 394 comments in 2006 but only 220 in 2007. This also includes my own comments; maybe I should represent my comments separately.
Average number of characters in posts
This graph clearly shows that average number of characters in my posts. Even though I have written fewer posts in 2007, the average number of characters has increased, which is good (which also means that I have become very talkative ๐ ). This is very good and is also motivating. In 2008 I should keep up the length of the posts and at the same time should also try to increase their number.
Total number of characters in posts
This graph clearly shows that even though I have written fewer posts, I have almost written the same amount of characters in 2007 when compared with 2006, which is again motivating.
I have really become addicted to stats now and will try to dig more deep into my blog to unearth other valuable information when I get some time. This explains why everybody was soo fascinated by Yuvi’s cool graphs.
Meanwhile you can also publish your yearend stats by using my Year End Stats WordPress Plugin. So what does your yearend stats speak about your blogging habit? Please leave a link to your yearend stats in the comments so that I can have a look at it.
PS: I would really love to see how Yuvi has scaled up this year. May be Yuvi, do it when you find time in between your exams.
Posted in API's/Mashup, WordPress Tagged Google Charts, stats, WordPress, Year End Stats 2 Comments
Back from pipesCamp
As planned, I attended pipesCamp yesterday and it was really worth the time spent. As planned, I took Yuvi with me and he started to click his camera on the way itself, and he got some 35 – 40 snaps before we could reach there. (Yuvi, I know that your computer has crashed, but I am waiting for your photos to appear in Flickr as soon as possible. ๐ )
I meet lot of cool people there and true to the unconference style we had a couple of presentations about Yahoo Pipes (and some slides from the official Yahoo pipes team itself) and then some open discussions about pipes and blogging in general.
Then towards the end of the day we had “hackday” kind of competition and we were given 60 minutes to design/code a pipe and then 3 minutes to demonstrate the demo. Myself, Yuvi and Harish got together and created a pipe called “Ego Search“. (Harish, thanks for the laptop ๐ )
Ego Search is a pipe for finding out how popular you are on the web, based on search results from popular search engines. The popularity chart is drawn based on the number of search results that point to your blog or domain name for your name. And if your name is say ‘xyz’, a 100 point popularity rating on the graph says that you are the most populous ‘xyz’ that the search engine knows. You can try out the pipe in this url http://pipes.yahoo.com/sudar/egosearch. We also had some great pipes like MTC Mashup created by other cool people.
On the whole the first ever pipesCamp went very well. I will post links to photos and videos once they are available.
By the way anyone planning for the first ever WordCamp in India?
Posted in API's/Mashup, Events/Conferences Tagged Events/Conferences, Pipes, Yahoo 4 Comments
Bloglines Notifier – My First Google Gadget
I didn’t have much to do last weekend and so I thought of giving a try to Google Gadget and ended up developing my first Google Gadget – Bloglines Notifier. As the name implies it will notify you the count of unread items in your Bloglines account. (Nothing special just a trivial one ๐ )
You need to enter your Bloglines account email id and it will retrieve the unread count using the Bloglines API and display it in the Gadget screen. The count will be automatically refreshed according to the interval set in the Gadget settings. Since Bloglines doesn’t need you to be authenticated before retrieving the unread count you don’t need to enter your Bloglines account password.
The Google Gadget API is very simple to start with but at the same time very powerful if you need to do complex or advanced things. If you are interested grab the Google Gadget API Developers Guide and get started. It’s actually that simple.
The full source code of this Gadget is available here and if you are interested you can add it to your personalized page by clicking this button.
Now I can have one icon less in my system tray. ๐ BTW if you guys have a nice idea for a Gadget, let me know I shall give a try.
Resources Used
Posted in API's/Mashup Tagged API's/Webservices, Bloglines, Gadgets, Google, Google Gadgets, Notifier 2 Comments
King Ping has a new logo
Thanks to Wes (Trafic Transit) King Ping now has a new logo now. The new logo looks cool and fits the design very much. Check out the logo at KPing.com.
Here is Fred’s comment about this.
Got a suggestion / Feedback / Comment / Feature Request, let us know we would be glad to hear that from you.
Posted in API's/Mashup Tagged KingPing 2 Comments