Improve the speed of your page

Just as I was looking at the Webmasters tool today I found a new FireFox add-on tool by Google called Page Speed. It helps you evaluate the performance of your web page and get suggestions to improve the speed/performance of your web page.

The below video gives you a quick overview of the tool which showcases some cool features, like javascript minify and others.

Another alternative to this is YSlow another FireFox add-on from Yahoo, to increase the performance of your webpage

Posted in Web Development, tools | Tagged | 2 Comments

Making a PHP CURL request to HTTPS url

Recently I had been trying to make a PHP CURL request to an HTTPS url for fetching the google analytics data over their secure server url. But all I was able to get was an nasty error.

“Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed”

I tried many way arounds to fix the problem until I found one solution which worked for me. All you need to do is download this cacert.pem file and specify the path through the CURLOPT_CAINFO option.

This is the way you do it.

curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem")

Save the downloaded file in a directory and specify the full path to cacert.pem file.

Important, Leave all other https related CURL options (eg. CURLOPT_SSL_VERIFYPEER) to default as you would have been doing for a non-https url.

Here is full snippet that makes an HTTPS request to google analytics API to get authentication token.

 
function auth(){
 
	global $ga_username;
	global $ga_password;
 
 
	$gaUrl = "https://www.google.com/accounts/ClientLogin";
	//	
 
	$authData = "accountType=GOOGLE&Email=". $ga_username ."&service=analytics&source=My app&Passwd=". $ga_password;
 
	// create a new cURL resource
	$ch = curl_init();
 
	// set URL and other appropriate options
	curl_setopt($ch, CURLOPT_URL, $gaUrl);
	curl_setopt($ch, CURLOPT_HEADER, 0);
 
	curl_setopt($ch, CURLOPT_POST, 1);
 
	curl_setopt($ch, CURLOPT_POSTFIELDS, $authData);
 
	curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem");
 
	$fileHandle = fopen(dirname(__FILE__) . "/error.txt","w+");
 
	curl_setopt($ch, CURLOPT_VERBOSE, true);
 
	curl_setopt($ch, CURLOPT_STDERR, $fileHandle);
 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
	// grab URL and pass it to the browser
	$response = curl_exec($ch);
 
	if(curl_exec($ch) === false)
	{
		echo 'Curl error: ' . curl_error($ch);
	}
	else
	{
		$tokens = explode("\n", trim($response));
 
		print_r($tokens);
 
	}
 
	// close cURL resource, and free up system resources
	curl_close($ch);
 
}
Posted in PHP Programming, Web Development | Tagged , , , | 2 Comments

The Originators

Today a funny email float into by In-box from my other programming fellows with a pun “Know Your Enemies” in the subject. It showed the picture of all those great people who created one or the other programming languages or software techniques or paradigms, and it really amused me.

All these masterminds have done a great job and have contributed a lot in shaping up today’s Computer, Web and IT industry and I really admire them. It was really nice to see how they really look. However, my fellow programming beings seem to be completely bored and frustrated with their daily routine work, tight schedules and absolutely no creativity in life, considering these people as the root of all their frustrations :) . But never mind, the creator of the email had just a noble intent to keep up a light humor in the life of that poor frustrated programmer when he opens up his email in morning.

So here are our enemies, oops… sorry the originators ;)

Creators or PHP, C, C++, JAVA, Javascript, Perl, MySQL and others. Click to enlarge.

Posted in Blogging, Life | Tagged , , | Leave a comment