Monday, 10 December 2012

Youtube API tutorial PHP - Setup in xampp

In this blog We're gonna see how to set up youtube api environment in php xampp. Google clearly gives the documentation for this here. But still I'm stuck at the middle somewhere. Because I've never configured this before. So this is absolutely for beginners.

Download the Google Data Client Library files from the zend website, as we use Zend Gdata for Youtube API. We dont have to install zend framework for this to work. Just download Zend_Gdata from the above link which is located at the bottom of the Zend framework page.

Extract the folder and add the location of the library folder to your PHP path. We can set the path by 2 ways. One by using set_include_path() method and other by using setting path using php.ini file. For me it is located in C:\xampp\php. Open php.ini and search for include_path variable. I extracted Zend_Gdata in C:\xampp\ and rename the folder as ZendGdata.

Now edit the include_path variable by including this path C:\xampp\ZendGdata\library. Make sure there is a library folder in that path. Now restart your apache server and test whether the script works by going to this script. It is installation checker script for this. If all the scripts were passed then it'll show no errors found. I got one error when running this script. It is openssl error. We can solve it by uncommenting ;extension=php_openssl.dll to extension=php_openssl.dll in php.ini file and restarting the apache server. Then I got no errors.

Now run the demo files in the demo folder of Zend_Gdata folder(copy the demo folder to htdocs folder). Thats It! It'll work like charm!

 

2 comments:

  1. Thanks for your article, it is really helpful for beginners.....

    ReplyDelete
  2. I'm getting following error

    Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Unable to Connect to ssl://gdata.youtube.com:443. Error #10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ' in C:\Work\xampp\ZendGdata\library\Zend\Gdata\App.php:696 Stack trace: #0 C:\Work\xampp\ZendGdata\library\Zend\Gdata.php(221): Zend_Gdata_App->performHttpRequest('GET', 'https://gdata.y...', Array, NULL, NULL, NULL) #1 C:\Work\xampp\ZendGdata\library\Zend\Gdata\App.php(883): Zend_Gdata->performHttpRequest('GET', 'https://gdata.y...', Array) #2 C:\Work\xampp\ZendGdata\library\Zend\Gdata\App.php(771): Zend_Gdata_App->get('https://gdata.y...', NULL) #3 C:\Work\xampp\ZendGdata\library\Zend\Gdata\App.php(213): Zend_Gdata_App->importUrl('https://gdata.y...', 'Zend_Gdata_YouT...', NULL) #4 C:\Work\xampp\ZendGdata\library\Zend\Gdata.php(162): Zend_Gdata_App->getFeed('https://gdata.y...', 'Zend_Gdata_YouT...' in C:\Work\xampp\ZendGdata\library\Zend\Gdata\App.php on line 696

    ReplyDelete