Document 198268

2010
BIRT Twitter Gadget
Twitter provides an xml feed of postings and what’s more it provides this for Twitter
searches. So if you have a web site or intranet site and you want to create a display of all
Twitter postings about a particular subject then this guide shows you how.
Paul Bappoo
[email protected]
http://www.BirtReporting.com
October 2010
CONTENTS
How To Contact The Author ........................................................................................................................... 4
Introduction .................................................................................................................................................... 5
Obtainign Your Twitter Feed .......................................................................................................................... 6
Creating the Report ........................................................................................................................................ 9
Limiting the Data .......................................................................................................................................... 14
Formatting the Report .................................................................................................................................. 16
Adding the Report to a Web Page ................................................................................................................ 19
Hosting BIRT ................................................................................................................................................. 20
More Information ......................................................................................................................................... 21
Paul Bappoo – BIRT Twitter Gadget
© COPYRIGHT 2010 by Paul Bappoo, all rights reserved.
This guide is furnished under license and may be used or copied only in accordance with the terms of such license. The content of this
guide is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by the
author. The author assumes no responsibility or liability for any errors or inaccuracies that may appear in this guide.
Except as permitted by such license, no part of this publication may be reproduced, stored in a retrieval system or transmitted, in any form
or by any means, electronic, mechanical, recording or otherwise, without the prior written permission of the author.
All product and company names are trademarks or registered trademarks of their respective holders.
HOW TO CONTACT THE AUTHOR
Email: Pau[email protected]
Web Site: http://www.BirtReporting.com
Paul Bappoo is the author of BIRT for Beginners (which is available in paperback from BIRTReporting.com,
Amazon and Barnes and Noble amongst others) and has been an international technical software
consultant and involved with computers for over 30 years. Paul has an interest in BIRT reporting,
enterprise application integration, automated software testing, computer based training and enterprise
system implementation. Paul runs the BIRT User Group UK and is a member of the BIRT-Exchange Advisory
Council. He would be delighted to hear from you with your tips, tricks and stories about your usage of
BIRT. If you have a question, a need for training or consulting or great tip to share with the community
then drop him a line.
INTRODUCTION
Many web sites show a Twitter feed of tweets about a specific subject or from a
particular author. There are many ways to achieve this, with “gadgets” that can be
applied to web sites, but we thought it would be fun to try and do this with BIRT. As it
turned out it was particularly straight forward and we present the “how to” in this guide.
The Twitter feed is designed to be embedded in an iframe in a web page, which could be
on your web site or intranet and it works based on the XML feed published by Twitter for
any search conducted on the site.
You could for example search for a particular term or hash tag. A has tag, is a commonly
used word in Twitter which is preceded by a # symbol.
There is a live example on the home page of BIRTReporting.com which displays all
Twitter posts featuring the hash tag #BIRT – of course!
Help the Community
We are on the lookout for contributions of rptdesign files and tips. If you have some
sample reports based on specific applications or on Classic Models or if you have any tips
about useful ways of achieving certain objectives with BIRT please send them over to me
so I can publish them on the BIRTReporting.com web site. Email you suggestions to
[email protected]
OBTAINING YOUR TWITTER FEED
Before you start creating your report you need to create a Twitter search from where you
can obtain the XML feed.
Visit http://search.twitter.com and you should see the following screen:
Now type in the search term you are interested in – we used #BIRT but you can use
anything relevant to you - and you should see the page of results:
Now, highlight and copy the address of the search results page. It will be something like
this:
http://search.twitter.com/search?q=%23BIRT
You can also display Tweets that are posted by a particular author by using the following
address:
http://search.twitter.com/search.atom?q=from:bappoo
Just replace “bappoo” in this example with the Twitter username of the account you wish to get
the feed for.
If you run this in a browser you will see a page of XML as follows:
CREATING THE REPORT
Create a new report in BIRT and create a new data source, selecting the XML Data Source
option:
In the next dialogue enter the Twitter feed address that you collected earlier:
Hit the Test Connection button to ensure that the connection is working. You should see
a message saying “Ping Succeeded”. Once this is done, hit Finish.
Next create a new data set, selecting your Data Source as the basis:
The default options are fine:
On the next screen, expand the Feed node until you get down to the Content entry. This
is the XML element that contains the actual Tweet. Highlighing the Content item, click
the little right pointing arrow in the middle of the screen.
In the next dialogue that appears, just accept the defaults and click OK. Your initial
screen should then look like this:
Press Next and again expand the tree until you find the Content node. Highlight it and
use the central arrow button to move it into the right hand column, accepting the defaults
in the dialogue that appears.
Click on Show Sample Data to see if the feed is returning anything:
LIMITING THE DATA
A twitter feed could contain a lot of entries. For example a search for a popular term or
hash tag could be very large indeed and would take a long time to render in a report.
Plus you wouldn’t have room for all the tweets on an average web page! So you need to
limit the number of records returned from the XML feed.
As you close the Data Set builder, BIRT opens the data set edit dialogue. From this
select the Settings option and enter the Max number of rows that you want your report to
return.
FORMATTING THE REPORT
Since this is going to form a “Widget” on a web page then it is important to format it so
that it fits within the iFrame that it is destined to go in and adopts a look and feel similar
to the host page.
For the feed on the home page of BIRTReporting.com I used a single column table with
a couple of header rows and a couple of detail rows. I also squashed the table up to be a
narrow column, just wide enough to fit where I wanted it on the web site.
From the palette select the Dynamic text object and place this into the first detail row of
the table. When the dialogue appears navigate to the Content item in the available
column bindings.
Next drag the name field into the second detail row.
Format the table background colours, headers, borders as you like and preview your
report.
ADDING THE REPORT TO A WEB PAGE
The report is displayed on a web page by including it in an iFrame. The HTML syntax for
this is:
<iframe src ="http://127.0.0.1:8888/BIRT-
Viewer/preview?__navigationbar=false&__toolbar=false&__showtitle=false
&__report=BIRTStore/BIRTTwitterFeed.rptdesign&__format=html" width="200"
height="200" frameborder="0" scrolling="no" >
<p>Your browser does not support iframes.</p>
</iframe>
The URL to run the report breaks down like this:
Item
Description
http://127.0.0.1:8888/BIRT-Viewer/
The address of the BIRT viewer on the
server
preview
Tells BIRT to run in preview mode – faster
and more tolerant to browser security
settings
?__navigationbar=false
Tells BIRT not to display the navigation bar
&__toolbar=false
Tells BIRT not to display the toolbar
&__showtitle=false
Tells BIRT not to display the title
&__report=BIRTTwitterFeed.rptdesign
The report to execute
&__format=html
Formats the report as HTML
By switching off scrollbars and the frame border we make the iframe content appear to
be part of the final web page:
HOSTING BIRT
If you want to use BIRT to generate content for a public web site, then you need to host
it. The hosting requirements will vary depending on the amount of traffic, the amount of
data to be served and the uptime requirements. However as a starting point, for low
traffic sites and for experimentation and learning you can get a good, inexpensive virtual
server, with full desktop access so you can install a database and BIRT from
http://www.1and1.co.uk
MORE INFORMATION
This book, written by Paul Bappoo, the founder of the
BIRT User Group UK presents an overview of the
open source BIRT tools and the commercial
enhancements available from Actuate, including...
Eclipse BIRT Designer, Actuate BIRT Designer,
iServer Express, Interactive BIRT viewer, Actuate
BIRT Studio, BIRT Spreadsheet Designer
With walkthrough tutorials of the main features,
including screenshots, from installation through data
selection to formatting reports and fully graphical
Flash charting this book will have you creating your
own reports from scratch in only a couple of hours.
If you are too busy to spend days learning software
and want tangible results fast then BIRT For
Beginners is for you.
When you buy the book you will automatically get
access to the readers section of this web site which
includes BIRT report request forms that you can
distribute to your end users, extra chapters in PDF
format and an ever growing library of reports,
tutorials, reviews, tips & tricks.
Buy the book and get free membership of BIRT Reporting and the BIRT User Group UK at:
http://www.BIRTReporting.com
Please feel free to share this address with your colleagues and inspire them to use BIRT to
create great looking reports.
I look forward to your feedback so please feel free to send me an email and let me know how you
get on with BIRT, provide feedback on this guide, share your tips and tricks, or request help for
specific problems. I can’t guarantee to personally solve everyone’s problems but there are some
great BIRT related forums out there and you can find a growing list of links and resources on my
site.
Paul Bappoo
[email protected]
http://www.BIRTReporting.com