Authenticate your website using Facebook Connect API

Posted on June 15th, 2009 by Mujeeb Rahman

Facebook connect API allows users to dynamically connect their identity information from Facebook, such as basic profile, friends, photos information and more, to third party websites, as well as desktop and mobile applications.  The article here describes how to provide Facebook Connect authentication for your web application.

Steps to connect your site to Facebook :

1. If you don’t already have a Facebook API key for your site, create an application with the Facebook Developer application.

  • Go to http://www.facebook.com/developers/createapp.php to create a new application.
  • Enter a name for your application in the Application Name field.
  • Accept the Developer Terms of Service, then click Save Changes.
  • If you have a Facebook API key,follow from next step

  • On the Basic tab, keep all of the defaults.
  • Take note of the API Key, you’ll need this shortly.
  • Click the Connect tab. Set Connect URL to the top-level directory of the site which will be implementing Facebook Connect. You can include a logo that appears on the Facebook Connect dialog. Next to Facebook Connect Logo, click Change your Facebook Connect logo and browse to an image file. The logo can be up to 99 pixels wide by 22 pixels tall, and must be in JPG, GIF, or PNG format.
  • If your site is going to implement Facebook Connect across a number of subdomains of your site , you need to enter a Base Domain
  • Click Save Changes.

2. Create a cross-domain communication channel file called xd_receiver.htm and place it in a directory relative to the Connect URL that you entered in the previous step. Include following script into this file.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript">
</script>
</body>
</html>

3. Next, in your Home Page ,ie page of facebook connect page,Place Html tag as following

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">

4. include following javascript file with in your body tag NOTE IN HEAD TAG

<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

5. Place facebook login Button in your page

<fb:login-button></fb:login-button>

6. Finally, Include following script after the login button

<script type="text/javascript"> FB.init("YOUR_API_KEY_HERE", "<path from web root>/xd_receiver.htm"); </script>

You should now be able to click on the facebook connect logo and use your facebook credentials to login to your web site.

  • Share/Save/Bookmark

Generating a Google Sitemap via PHP

Posted on June 15th, 2009 by Mahesh Murali

A sitemap is  an XML file,that lists the URLs of a site.  The sitemap file can be used to inform search engines like google on the pages available on a site and when those pages have been modified.  The search engines require a particular format for the sitemap xml file. Let me give a brief on sitemap creation for google.

Create an xml file(say sitemap.xml). Its better to create the xml file dynamically using the scripting language like php, jsp etc.

Format of sitemap xml  accepted by google:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
<url>
<loc>http://domain.tld/</loc>
<lastmod>2008-01-01</lastmod>
<changefreq>daily</changefreq>
<priority>0.1</priority>
</url>
</urlset>

The points to be remembered when creating a sitemap are:

1. Sitemap should start with the tag <urlset> and end with </urlset>
2. Each set of xml entry shouild start with <url> and end with </url>
3. <loc></loc> contains the url
4. The <lastmod> tag expects a date in the  format YYYY-MM-DD,  or the date format can be in w3c format.
5. The <changefreq> tag expects one of the  values: always, hourly, daily, weekly, monthly etc.
6. The <priority> can be a value between 1.0 and 10

7. Replace special charecters from xml file.
Character                   Replacement
Ampersand     &         &amp;
Single Quote    ‘         &apos;
Double Quote  “         &quot;
Greater Than   >        &gt;
Less Than       <        &lt;

8. Encoding should be UTF-8 mode
9. The maximum permitted size of a sitemap file is 10 MB.

Sample PHP  code for sitemap generation:

$xml = '';
$xml =  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"."\n";
$xml .= "<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"."\n";
for($i=0;$i<$subLimit;$i++){
$title = str_replace("&","&amp;",strip_tags($response['title']));
$loc = str_replace("&","&amp;",strip_tags($response['location']));
$com = str_replace("&","&amp;",strip_tags($response['company']));
//$loc1 = $row['job_jobs_location'];
$title = htmlentities($title, ENT_QUOTES, "UTF-8");
$com = htmlentities($com, ENT_QUOTES, "UTF-8");
$loc = htmlentities($loc, ENT_QUOTES, "UTF-8");
$date = $response['date'];
$date = strtotime($date);
$date = date(DATE_W3C, $date);   //Date in w3c format
$xml .= "<url>"."\n";
$xml .= "<loc>http://www.jobtreks.com/jobresult/$title/$com/$loc/$id</loc>"."\n";
$xml .= "<lastmod>$date</lastmod>"."\n";
$xml .= "<priority>0.50</priority>"."\n";
$xml .= "<changefreq>weekly</changefreq>"."\n";
$xml .= "</url>"."\n";}
$xml .= "</urlset>";
$fh = fopen('sitemap.xml', 'w'); //After exceuting this file, an xml file called sitemap.xml is created.
  • Share/Save/Bookmark

Programming With Twitter API

Posted on June 5th, 2009 by Mujeeb Rahman

Twitter is a popular social networking service where users can share their updates. User updates known as tweets which are text based posts up to 140 characters, displayed on the user’s profile page and delivered to other users who have subscribed to them called followers. Twitter has gained significant attention from web savvy social networkers, and lately also being used by businesses for marketing.

Twitter provides API that allows developers integrate twitter functions on their sites. Using the API, developers are now able to build desktop and web based messaging applications. These APIs have allowed for hundreds of exciting applications to be made available that allows friends to keep in constant contact.

The Twitter API currently consists of two discrete APIs, REST and Search APIs. We are not allowed to make unlimited calls in this API. The API is entirely HTTP-based. Methods to retrieve data from the Twitter API require a GET request. Methods that submit, change, or destroy data require a POST. A DELETE request is also accepted for methods that destroy data. API Methods that require a particular HTTP method will return an error if you do not make your request with the correct method. The API presently supports XML, JSON, and the RSS and Atom syndication formats, with some methods only accepting a subset of these formats.

Some of Search API Methods are shown below:
search: Returns tweets that match a specified query.
URL: http://search.twitter.com/search.format
Formats:json,atom  Example:http://search.twitter.com/search.atom?q=devo&rpp=15
Here rpp is the records per page
Trends: trends:Returns the top ten topics that are currently trending on  Twitter.
URL: http://search.twitter.com/trends.format
Format: json
We can fetch current topics,daily topics or weekly topics.
Example:http://search.twitter.com/trends/daily.json?date=2009-03-19

Some of REST API Methods shown below:

statuses/public_timeline : Returns the 20 most recent statuses from  non-protected users who have set a custom user icon
URL: http://twitter.com/statuses/public_timeline.format
Formats: xml, json, rss, atom.
Example: http://twitter.com/statuses/public_timeline.xml
 statuses/friends_timeline:Returns the 20 most recent statuses posted  by the authenticating user and that user's friends.
URL: http://twitter.com/statuses/friends_timeline.format
Formats: xml, json, rss, atom
Example:http://twitter.com/statuses/friends_timeline.xml
Status Methods:Returns a single status, specified by the id  parameter below.
URL:http://twitter.com/statuses/show/id.format
Formats: xml, json, rss, atom
Example: http://twitter.com/statuses/show/123.xml
  • Share/Save/Bookmark

Cabot selected as best Web Developers on oDesk for May 2009

Posted on June 2nd, 2009 by Shibu Basheer

Cabot Solutions, team member Mujeeb Rahman was selected best web developer on Odesk for May 2009.

We even got a badge to prove it!

best freelance web developers

Congratulations Mujeeb on this achievement, and thanks to our clients for their continued support.

  • Share/Save/Bookmark

java.lang.OutOfMemoryError when indexing large databases in Solr

Posted on May 16th, 2009 by Shibu Basheer

When indexing large databases in Solr, if you encouter java.lang.OutOfMemoryError, this could be caused due to a bug in the mysql jdbc driver.  To resolve this, add include batchSize=”-1″ parameter in your dataSource entry of you data-import.xml file.  The entry should look something like :

<dataSource type="JdbcDataSource" name="ds-2"
          driver="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost:8889/mysqldatabase" batchSize="-1"
          user="root" password="root"/>

Reference:

http://wiki.apache.org/solr/DataImportHandlerFaq#head-346bc6622c328a146d1691bc4ed6deb51086d9b3
  • Share/Save/Bookmark

Using Solr / Lucene for full text search with MySQL DB

Posted on May 14th, 2009 by Shibu Basheer

Solr is a standalone webservice application that can be installed on any servlet container like tomcat, jetty etc.  It uses the popular Lucene java library to provide enterprise level search results from databases, filesystem, web services etc.    Solr runs as a web service, so in effect it provides a cross platform search engine.  The results can be accessed from php, java, RoR or .NET by invoking its web service.  The only requirement on your server is that it should allow you to run java application or have deploy solr as a webapp in an existing servlet container such as tomcat or jetty.

This article shows how to get Solr index and provide search results for a simple MySQL table.  The search results will be provided in XML, so you can get your web application to read the results, parse it and display it any form desired. Read the rest of this entry »

  • Share/Save/Bookmark

’Cabot Trail’ in Munnar!

Posted on May 11th, 2009 by Venkatesh Thyagarajan

I am not sure if the road to Munnar can be compared to the famous North American Shore drive, Cabot Trail, but this past weekend, there was surely some Cabot in the air at Munnar where our team headed out for a fun team building trip. The trip has been long in the planning and the last delay is attributed to me and the team waited patiently for me to join the organization and then go on the trip. Read the rest of this entry »

  • Share/Save/Bookmark

Follow us on Twitter..

Posted on May 1st, 2009 by Shibu Basheer

Yes, we are on twitter now as cabotsolutions.

Out twitter url is http://www.twitter.com/cabotsolutions/

  • Share/Save/Bookmark

PHP development with SVN using Eclipse PDT and Subclipse in Ubuntu 8.10

Posted on May 1st, 2009 by Shibu Basheer

Eclipse’s PDT project provides an excellent development tool for LAMP developers.  It provides  great features like code completion, zend debugger,  error checking and all the goodness that comes with default eclipse package.   One of the nice things that PDT lacks out of the box is SVN support.  This can be easily achieved using subclipse plugin available for eclipse.   This is how you would install PDT, subclipse and get productive in less than 15 minutes (depending on your bandwidth).  For this article, we are using Ubuntu 8.10, so change use commands specific to your favorite flavour of linux. Read the rest of this entry »

  • Share/Save/Bookmark

Getting Openfire Groups to work with Zimbra OpenLDAP Authentication

Posted on April 10th, 2009 by Shibu Basheer

Its quite easy to get openfire and spark messenger to authenticate with Zimbra’s OpenLDAP by selecting OpenLDAP directory server during initial openfire setup.  One of the biggest drawbacks is that the groups feature will not be available.  Group feature is important for enterprises with large number of users and wnat to provide preset groups in spark like IT, HR, Sales etc. Read the rest of this entry »

  • Share/Save/Bookmark