I am working on a java application, which asks for a url as input, and outputs some analyses on that site url, into a pdf report.
I want to add the number of facebook likes for that url/domain, to the pdf report.
At the facebook site, I searched and found the following code sample (in javascript) that obtains this data–
Javascript code–
<h1>Number of likes-</h1>
<fb:like href="http://www.fbrell.com"></fb:like>
The output looks like this (in a regular web page)–
Number of likes-
Like 14,296 people like this. Be the first of your friends.
Note that for ‘Like’ an image with Like written on it, is shown.
I just want to put the number of people figure for number of likes, to be shown in my pdf report. Currently the java application is a desktop application, but can be converted into java web application with minimal effort. I am using the itext library for creation of pdf.
Is there some way to obtain the data as shown above, for output into the report.
There is a way of calling java methods from java script an vice versa, but for this you will need to remake your desktop application to java applet(probably also need to sign this).
So the procedure could be:
1) Extract the data you need form web site
2) Call from Java the JavaScript function which parses the site and return the number of likes
3) Insert number of likes to the rest of data from web site
Quite simple example of how calling JavaScript function from Java can be found here
Hope this helps,
Serhiy