Sunday 22 May 2011

How to add Tweets to your blog and debugging basic JavaScript: Why did Twitter.com/JavaScript/Blogger JSONP Widget stop working?

How to add Tweets to your blog and debugging basic JavaScript: Why did Twitter.com/JavaScript/Blogger JSONP Widget stop working?: "

I have a little yellow bar at the top of my blog that is supposed to show my latest Tweet. It's a nice unobtrusive way to show that I'm out there and I'm active, and maybe if the tweet is interesting to you, you'll stop by Twitter and follow me.

However, I noticed it stopped working recently. It was blank:

image

Static picture of a list of tweetsWeird. It'd worked great for years, plural. I searched around and found a few posts on GetSatisfaction asking about it, some recent, some not recent at all. Some people are having the code work on some accounts and not others.

Unfortunately, Twitter seems to have quietly deprecated the code I was using. It's still there but there are no pages on Twitter on how to add tweets to your blog in a low-level controlled way.

Twitter wants you to visit http://twitter.com/badges and use their existing Twitter Widgets. These are very typical of other sites, in that they are boxes with your tweets in them.

For example, here's a box of Tweets to the right, however, that's a little garish for my tastes.

Here's the code I was using to show just the very first tweet on the top of page. First at the top of the page I have a div that will hold my most recent tweet.

<div id="twitter_div">
<a href="http://twitter.com/shanselman" id="twitter-link" >Latest Tweet: </a>
<span id="twitter_update_list"></span>
</div>


Then later at the bottom I have these two scripts. These are what appear to be either not supported or not advertised by Twitter anymore.



<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/shanselman.json?callback=twitterCallback2&count=1"></script>


Now, don't use it just like that if you want to get only 1 original tweet as I do. Because it's this very code that stopped working recently. Except it stopped working sometimes. But did it?



To figure it out quickly, first I visited this URL in my browser. It returns JSON of all my tweets.



http://twitter.com/statuses/user_timeline/shanselman.json?count=1



However sometimes I get this:



[]


Yes, really. An empty JSON array. But why? Well at this moment in time my "most recent tweet" is actually a native retweet. It's not a tweet from me, it's a retweet of a YouTube video. See below?



A native REtweet next to a real tweet



Perhaps this JSON Twitter API was created before the Native Retweet was invented. But, if I tweet something fresh, at hit http://twitter.com/statuses/user_timeline/shanselman.json?count=1 again, I'll see this minimized JSON:



[{"in_reply_to_status_id":null,"text":"Testing for a blog post. Move along. This tweet never happened.","created_at":"Thu May 12 23:44:13 +0000 2011","favorited":false,"retweet_count":0,"source":"web","in_reply_to_screen_name":null,"in_reply_to_status_id_str":null,"id_str":"68823826439487488","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"place":null,"coordinates":null,"geo":null,"in_reply_to_user_id":null,"truncated":false,"user":{"is_translator":false,"notifications":false,"created_at":"Tue May 01 05:55:26 +0000 2007","profile_sidebar_border_color":"b8aa9c","listed_count":3909,"following":true,"description":"Tech, Diabetes, Parenting, Race, Linguistics, Fashion, Podcasting, Media, Culture, Code, Ratchet.","show_all_inline_media":true,"geo_enabled":true,"profile_use_background_image":true,"profile_image_url":"http:\/\/a1.twimg.com\/profile_images\/1344567304\/image_normal.jpg","contributors_enabled":false,"verified":false,"profile_background_color":"d1cdc1","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/157325454\/twilk_background_4ca8e4832a970.jpg","screen_name":"shanselman","default_profile_image":false,"statuses_count":40900,"id_str":"5676102","default_profile":false,"friends_count":2616,"profile_text_color":"696969","lang":"en","profile_sidebar_fill_color":"b8aa9c","followers_count":36994,"protected":false,"location":"Portland, Oregon","follow_request_sent":false,"profile_background_tile":true,"favourites_count":2089,"name":"Scott Hanselman","url":"http:\/\/hanselman.com","id":5676102,"time_zone":"Pacific Time (US & Canada)","utc_offset":-28800,"profile_link_color":"72412c"},"id":68823826439487488}]


I can run it by the http://jsbeautifier.org and it looks lovely...



[{
"in_reply_to_status_id": null,
"text": "Testing for a blog post. Move along. This tweet never happened.",
"created_at": "Thu May 12 23:44:13 +0000 2011",
"favorited": false,
"retweet_count": 0,
"source": "web",
"in_reply_to_screen_name": null,
"in_reply_to_status_id_str": null,
"id_str": "68823826439487488",
"contributors": null,
"retweeted": false,
"in_reply_to_user_id_str": null,
"place": null,
"coordinates": null,
"geo": null,
"in_reply_to_user_id": null,
"truncated": false,
"user": { ..... SNIP! .....
}
}]


So, Twitter has a nice JSON API that is old and doesn't support Native Retweets but I want the most recent tweet, my way.



Bam. http://twitter.com/statuses/user_timeline/shanselman.json?count=5



Of course, if my last five tweets are all Native Retweets then it all falls part, but you get the idea.



image



If I was really serious, I could even remove @replies, only showing original tweets, remembering that this JSON API doesn't include Native Retweets in its results.



I found some code on BarneyB's blog that is a modification of Twitter's original code. He mentions in the comments that he's removing replies in his code. I just took his code and stop the code as soon as a valid original non-replied tweet is found. In this case, I search the 5 tweets I requested that were returned from Twitter. If it turns out I reply a lot and get an empty payload, maybe I'll increase that number.



The conclusion here is that this code still "works," it just doesn't see Native Retweets:



<div id="twitter_div">
<a href="http://twitter.com/shanselman" id="twitter-link" >Latest Tweet: </a>
<span id="twitter_update_list"></span>
</div>


Then later...



<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/shanselman.json?callback=twitterCallback2&count=1"></script>


My issue was that I want a single tweet, specifically the first original, non-native-retweet, non-reply tweet. I solved it by taking BarneyB's @reply-filtering code and adding a check that breaks out of the loop. I ask Twitter for 5 tweets, but as soon as I find one from that lists of candidates, that's the one. Feel free to View Source if you like, or just be aware of the limitation of Twitter's (possibly deprecated) JSONP API.



It was a trivial but fun lunch hour, indeed.



UPDATE: Great comment below from Dave Ward. He points out that I could have my cake and eat it too by using the new API and a "include_rts" flag like this:



https://api.twitter.com/1/statuses/user_timeline.json?screen_name=shanselman&include_rts=true&count=10&callback=twitterCallback2



Thanks Dave!



© 2011 Scott Hanselman. All rights reserved.



"

" The Roving Giraffe News Report " provided by Ace News

Wednesday 9 February 2011

Springloops – Advanced Source Code Management Platform

Springloops – Advanced Source Code Management Platform: "

Info: This is a review of a paid application (free during beta).


Source code management is a "must" for any developer team working on the same project to get updated on any changes made to the code and make sure every change is backed up.


Springloops, the popular source code management platform has released the V2 of their product which is more powerful with a new user interface, Git integration (besides Subversion) and ticketing support.


Springloops Deployment


The files for a project can be imported from a repository or as a zipped file. Also, they can be set as private or public.


The platform is an all-in-one for managing development projects as it has the features of a project management application as well (with milestones and tickets that can be assigned to users). And, it can integrate tightly with Basecamp.


Springloops Git


Springloops has a very detailed knowledgebase that not only helps you get the basics of version control (if you're not experienced with it) but also covers answers to any possible questions regarding the service.


The V2 of the platform is currently in beta status and free-to-use with unlimited projects until it is out of beta. Simply, a good chance to give the service a try.


Special Downloads:

Ajaxed Add-To-Basket Scenarios With jQuery And PHP

Free Admin Template For Web Applications

jQuery Dynamic Drag’n Drop

ScheduledTweets


Advertisements:

Professional XHTML Admin Template ($15 Discount With The Code: WRD.)

Psd to Xhtml

SSLmatic – Cheap SSL Certificates (from $19.99/year)




"

" The Roving Giraffe News Report " provided by Ace News

Modular Grid Pattern: Grids For Photoshop & Other Image Editing Apps

Modular Grid Pattern: Grids For Photoshop & Other Image Editing Apps: "

Modular Grid Pattern is a website which enables you to create customizable grids in several ways.


The first one is a free Adobe Photoshop extension (CS5 compatible) provided which makes creating the grid directly inside the application possible.


Modular Grid Pattern


Also, there is an online generator where you can mention baseline, gutter, module width/height, number of modules and the width of the layout where the application creates:



  • PNG pattern (for GIMP)

  • Photoshop pattern

  • transparency mask (for Adobe Fireworks)


accordingly.


Special Downloads:

Ajaxed Add-To-Basket Scenarios With jQuery And PHP

Free Admin Template For Web Applications

jQuery Dynamic Drag’n Drop

ScheduledTweets


Advertisements:

Professional XHTML Admin Template ($15 Discount With The Code: WRD.)

Psd to Xhtml

SSLmatic – Cheap SSL Certificates (from $19.99/year)




"

" The Roving Giraffe News Report " provided through Ace News Service

Sunday 29 August 2010

The Rise of Social Network Ad Spending

The Rise of Social Network Ad Spending: "

Social network ad spending is one again on the rise, argues a recent study by eMarketer, which predicts that US advertisers will spend nearly $1.7 billion on social sites this yea. This estimate is a noticeable increase from initial 2010 projection made by eMarketer, which forecasted $1.3B for this year, as well as a 20% increase from 2009 spending. Of this spending, Facebook is expected to receive about half of all social network ad spending, at least in the US, with Myspace losing ground to the now preeminent social networking site. These points, as well the study’s other most interesting facts and figures are featured in the below graphic.




Flowtown: Quickly turn emails into social profiles



Flowtown: Quickly turn emails into social profiles


"

" The Roving Giraffe News Report " provided by Ace News

Map Of Online Communities Reveals Staggering Social Media Shifts (PICTURES)


Really good look at the Social Media Map of sites and how they perform across the web, really good article. It is amazing how the social maps have changed over time from the early days of facebook and twitter and how they are helping to make others recede into the background.
Read the Article at HuffingtonPost

Saturday 28 August 2010

New Twitter widget update includes OAuth support

New Twitter widget update includes OAuth support: "

We just released a new version of the Twitter widget to support OAuth. We did this because in the coming hours Twitter will no longer support the traditional method with login and password which was used until now.



The only thing that will change for you is that you’ll have to click on an “Connect” button in order to allow the widget to interact with your timeline. That’s all. Easy, isn’t it?


If you’re curious, you can read Twitter’s official announcement and if you want to have more information about OAuth I’d recommend you the following Wikipedia page. You can also check OAuth’s official website to have more information about the protocol.


Don’t hesitate to contact our support team in case you have any trouble with this migration.







Related posts:

  1. Twitter widget update

  2. Build a Twitter Dashboard–All From a Single Twitter Widget!

  3. Netvibes Introduces New Drag-and-Follow Facebook, MySpace and Twitter Widget

"

" The Roving Giraffe News Report " provided by Ace News

Introducing Djinngo Mobile SDK

Introducing Djinngo Mobile SDK: "

Netvibes mobile partner Djinngo (see “Orange partners with Netvibes…”) is proud to introduce the Djinngo Mobile SDK to create your own widgets and advanced apps for mobile phones.



Djinngo developers from Djinngo on Vimeo.


Do you want to download SDK and development tools? It’s very easy:




Share your experience and meet the djinngo team on the dedicated board.


And don’t forget to follow djinngo on Twitter!







Related posts:

  1. Orange partners with Netvibes to offer the world’s largest collection of mobile widgets

  2. Going mobile: netvibes in your pocket

  3. Netvibes Premium Dashboard Manager: Introducing a whole new business dashboarding experience

"