Showing posts with label Zend Framework. Show all posts
Showing posts with label Zend Framework. Show all posts

Friday 8 May 2015

Youtube v3 API Sample API Requests and Response - Search Videos - Get Video Details

Youtube v3 API Sample API Requests and Response - Search Videos - Get Video Details


For youtube v3 API, you must need an API_KEY for video search, get video details, upload video and delete video etc.
In each request, you need to pass the APK_KEY to get the records, If you didn't pass the API_KEY, you will not get the response from youtube api.

In Youtube V2 API_KEY is not required, but its is compulsary for youtube V3 API.
google has stopped the youtube v2 API so you must use V3 API.

If you don't have API_KEY, please get the API Key from http://code.google.com/apis/console#access .
You must need google account for youtube v3 API.
Youtube v3 API Sample API Requests and Response - Search Video List - Get Video Details


Now, I am assuming you have valid API_KEY. if you have added referer while creating API, then you can use API_KEY for that domain only. Yeah you can add multiple domain for 1 key.
Suppose we have following API_KEY.
API_KEY: AIzaSyBqXp0Uo2ktJcMRpL_ZwF5inLTWZfsCYqY

Also you must enable the "YouTube Data API" from google console for the same key.

Get List of youtube Videos (By Default It will gives 4 videos)
https://www.googleapis.com/youtube/v3/search?part=snippet&key=AIzaSyBqXp0Uo2ktJcMRpL_ZwF5inLTWZfsCYqY


Get List of youtube videos (Search 40 videos)
https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=40&key=AIzaSyBqXp0Uo2ktJcMRpL_ZwF5inLTWZfsCYqY


Get List of youtube videos (Search 40 videos + having keyword "sports" )
https://www.googleapis.com/youtube/v3/search?part=snippet&q=sports&maxResults=40&key=AIzaSyBqXp0Uo2ktJcMRpL_ZwF5inLTWZfsCYqY


Get List of youtube videos( Search with 100km of 37.42307,-122.08427(lat/long)
https://www.googleapis.com/youtube/v3/search?locationRadius=100km&part=snippet&location=37.42307%2C-122.08427&type=video&key=AIzaSyBqXp0Uo2ktJcMRpL_ZwF5inLTWZfsCYqY


Get List of youtube videos (search videos which are tags with sports [videoCategoryId=17])
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&videoCategoryId=17&key=AIzaSyBqXp0Uo2ktJcMRpL_ZwF5inLTWZfsCYqY


Response Format:
{"kind":"youtube#searchListResponse","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/okahf16vRr9O67w1AX2xksAkmDI\"","nextPageToken":"CAUQAA","pageInfo":{"totalResults":1000000,"resultsPerPage":5},"items":[{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/EIQjGNXfg22wA149MrmBxBM3QX4\"","id":{"kind":"youtube#video","videoId":"a2RA0vsZXf8"},"snippet":{"publishedAt":"2010-11-21T05:14:05.000Z","channelId":"UCplkk3J5wrEl0TNrthHjq4Q","title":"\"Just A Dream\" by Nelly - Sam Tsui & Christina Grimmie","description":"Check out our epic song with Coke Bottles! https://www.youtube.com/watch?v=ZzuRvzsNpTU Hope you guys like this duet between Christina Grimmie and Sam ...","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/a2RA0vsZXf8/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/a2RA0vsZXf8/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/a2RA0vsZXf8/hqdefault.jpg"}},"channelTitle":"KurtHugoSchneider","liveBroadcastContent":"none"}},{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/3bB0h6KJXx-TPbAqXKd5nADWGX0\"","id":{"kind":"youtube#video","videoId":"Ahha3Cqe_fk"},"snippet":{"publishedAt":"2011-11-11T18:37:24.000Z","channelId":"UC-8Q-hLdECwQmaWNwXitYDw","title":"Katy Perry - The One That Got Away","description":"Sometimes you promise someone forever but it doesn't work out that way. Watch Katy Perry and Diego Luna star in the sixth chapter of the “Teenage Dream” ...","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/Ahha3Cqe_fk/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/Ahha3Cqe_fk/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/Ahha3Cqe_fk/hqdefault.jpg"}},"channelTitle":"KatyPerryVEVO","liveBroadcastContent":"none"}},{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/VZLQn8wfLOJ60oe6Bced9ryD7Kg\"","id":{"kind":"youtube#video","videoId":"NV7xJ73_eeM"},"snippet":{"publishedAt":"2014-11-17T14:00:19.000Z","channelId":"UCMu5gPmKp5av0QCAajKTMhw","title":"Romeo and Juliet vs Bonnie and Clyde. Epic Rap Battles of History Season 4","description":"Download on iTunes ▻ http://bit.ly/1yN7aai ◅ Season 3 Autographed CDs available at ▻ http://shop.erb.fm ◅ Subscribe for more battles! http://bit.ly/1ElwJ40 ...","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/NV7xJ73_eeM/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/NV7xJ73_eeM/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/NV7xJ73_eeM/hqdefault.jpg"}},"channelTitle":"ERB","liveBroadcastContent":"none"}},{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/IN61vHPZ3FNoK9mme_Kf9E0U50c\"","id":{"kind":"youtube#video","videoId":"XjwZAa2EjKA"},"snippet":{"publishedAt":"2013-11-20T08:03:53.000Z","channelId":"UC-8Q-hLdECwQmaWNwXitYDw","title":"Katy Perry - Unconditionally (Official)","description":"Download \"Unconditionally\" from Katy Perry's 'PRISM': http://smarturl.it/PRISM Official video for Katy Perry's \"Unconditionally\" directed by Brent Bonacorso and ...","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/XjwZAa2EjKA/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/XjwZAa2EjKA/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/XjwZAa2EjKA/hqdefault.jpg"}},"channelTitle":"KatyPerryVEVO","liveBroadcastContent":"none"}},{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/gKZhz62FdXndZR7dJdi_PDTpe9U\"","id":{"kind":"youtube#video","videoId":"-kWHMH2kxXs"},"snippet":{"publishedAt":"2014-11-01T04:10:36.000Z","channelId":"UC8-Th83bH_thdKZDJCrn88g","title":"Wheel of Impressions with Kevin Spacey","description":"In this Halloween edition of Wheel of Impressions, Jimmy and Kevin take turns doing random celebrity impersonations, such as Christopher Walken talking ...","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/-kWHMH2kxXs/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/-kWHMH2kxXs/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/-kWHMH2kxXs/hqdefault.jpg"}},"channelTitle":"latenight","liveBroadcastContent":"none"}}]}



Get Youtube Videos by Channel
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCv7IjJclSgpfGUHnG171ovw&order=date&key=AIzaSyBpu8hgnXbkqFVWrAvwRUEz7T13ii3I7WM
Response Format:
{"kind":"youtube#searchListResponse","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/q7tdIBpMwbnE_LWyfCaBtuEXMes\"","nextPageToken":"CAUQAA","pageInfo":{"totalResults":296,"resultsPerPage":5},"items":[{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/kvgjXpyJJ1CVnWs7i6kI_3-X0go\"","id":{"kind":"youtube#video","videoId":"drsH-pNpxho"},"snippet":{"publishedAt":"2015-04-23T14:21:19.000Z","channelId":"UCv7IjJclSgpfGUHnG171ovw","title":"A4 Pain - Painkiller #7 by Fez","description":"Insane new episode from A4 Pain Player: A4 Pain https://www.youtube.com/channel/UCVSS_0NReZbN3phT1OSKseQ Editor: Fez TOS ...","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/drsH-pNpxho/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/drsH-pNpxho/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/drsH-pNpxho/hqdefault.jpg"}},"channelTitle":"TheApokalypse4","liveBroadcastContent":"none"}},{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/t-udHC0CmSmK9Ej_q8KQgfHpyAo\"","id":{"kind":"youtube#video","videoId":"4kq8pW3ML0M"},"snippet":{"publishedAt":"2015-04-09T20:09:46.000Z","channelId":"UCv7IjJclSgpfGUHnG171ovw","title":"Apokalypse4 Killcams of the week - Episode 12","description":"Yes this is a weekly, episode we're trying to bring out more content for you guys, this is a example. Hope you enjoy! [CLICK SHOW MORE] This weeks winners!","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/4kq8pW3ML0M/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/4kq8pW3ML0M/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/4kq8pW3ML0M/hqdefault.jpg"}},"channelTitle":"TheApokalypse4","liveBroadcastContent":"none"}},{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/2_P60vNc53lyEX63yeKf_wlXYSk\"","id":{"kind":"youtube#video","videoId":"faizfXUbCAc"},"snippet":{"publishedAt":"2015-04-05T15:35:47.000Z","channelId":"UCv7IjJclSgpfGUHnG171ovw","title":"Apokalypse4 Challenges you - Episode 13","description":"Winner's chosen on the 1st of May, submit your ONLINE responses through twitter to @tehapokalypse4 and follow us for further information, good luck guys!","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/faizfXUbCAc/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/faizfXUbCAc/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/faizfXUbCAc/hqdefault.jpg"}},"channelTitle":"TheApokalypse4","liveBroadcastContent":"none"}},{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/JVw8gcWNDBq6A0k3NzNYydX7n4A\"","id":{"kind":"youtube#video","videoId":"vHTMfV7sJVg"},"snippet":{"publishedAt":"2015-03-25T16:10:24.000Z","channelId":"UCv7IjJclSgpfGUHnG171ovw","title":"A4 Sponge: Cleaning up - Episode 1","description":"Insane feeder and editor collaborate and produce a insane episode, enjoy guys! Subscribe :) http://bit.ly/SubToA4 10000 Teamtage ...","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/vHTMfV7sJVg/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/vHTMfV7sJVg/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/vHTMfV7sJVg/hqdefault.jpg"}},"channelTitle":"TheApokalypse4","liveBroadcastContent":"none"}},{"kind":"youtube#searchResult","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/imFn4cchjV1Gbp9F2zt9P-FgIvU\"","id":{"kind":"youtube#video","videoId":"AAMk41lxuyA"},"snippet":{"publishedAt":"2015-03-09T19:47:21.000Z","channelId":"UCv7IjJclSgpfGUHnG171ovw","title":"TheFantastic4 - ft. Gibby, Frizzy, Metal, Pregs by Cayzuh","description":"the ex a4 players return one last time. gibby https://www.youtube.com/user/ByGibbio frizzy https://www.youtube.com/user/OnyxFreeZy metal ...","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/AAMk41lxuyA/default.jpg"},"medium":{"url":"https://i.ytimg.com/vi/AAMk41lxuyA/mqdefault.jpg"},"high":{"url":"https://i.ytimg.com/vi/AAMk41lxuyA/hqdefault.jpg"}},"channelTitle":"TheApokalypse4","liveBroadcastContent":"none"}}]}




Get youtube video Detail
To get the youtube video detail, you must have an valid youtube video.
https://www.googleapis.com/youtube/v3/videos?id=a2RA0vsZXf8&part=snippet,statistics&key=AIzaSyBqXp0Uo2ktJcMRpL_ZwF5inLTWZfsCYqY
Response Format:
{"kind":"youtube#videoListResponse","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/5O69VO4RLDboG2ONvOiRwnoX77I\"","pageInfo":{"totalResults":1,"resultsPerPage":1},"items":[{"kind":"youtube#video","etag":"\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/7xlJyY3lj1NCugehSg-sBnEM0YQ\"","id":"a2RA0vsZXf8","snippet":{"publishedAt":"2010-11-21T04:52:18.000Z","channelId":"UCplkk3J5wrEl0TNrthHjq4Q","title":"\"Just A Dream\" by Nelly - Sam Tsui & Christina Grimmie","description":"Check out our epic song with Coke Bottles! https://www.youtube.com/watch?v=ZzuRvzsNpTU\n\nHope you guys like this duet between Christina Grimmie and Sam Tsui on \"Just A Dream\" originally by Nelly!\n\nAnd if you don't know Christina, definitely check out her stuff and subscribe to her, because she rocks!!\nhttp://www.youtube.com/zeldaxlove64\n\nShare this on Facebook!  http://on.fb.me/JustADreamSamChristina\n\nWe just opened an online store with shirts, cd's and other cool stuff here:\nhttp://www.kurthugoschneider.com/store\n\n\n--------------\n\nLinks\n\nKURT SCHNEIDER\nFacebook- http://www.facebook.com/KurtHugoSchneider\nTwitter- http://www.twitter.com/KurtHSchneider\n\nSAM TSUI\nFacebook- http://www.facebook.com/SamTsuiMusic\nTwitter- http://www.twitter.com/SamuelTsui\n\n---------------\n\n'Just A Dream' (originally Performed By Nelly)\nWritten By: Cornell Haynes, Frank Romano, Jim Jonsin, James Scheffer, Richard Butler\nPublished By: Universal Music Publishing / EMI Music Publishing / Reach Global Inc.","thumbnails":{"default":{"url":"https://i.ytimg.com/vi/a2RA0vsZXf8/default.jpg","width":120,"height":90},"medium":{"url":"https://i.ytimg.com/vi/a2RA0vsZXf8/mqdefault.jpg","width":320,"height":180},"high":{"url":"https://i.ytimg.com/vi/a2RA0vsZXf8/hqdefault.jpg","width":480,"height":360},"standard":{"url":"https://i.ytimg.com/vi/a2RA0vsZXf8/sddefault.jpg","width":640,"height":480},"maxres":{"url":"https://i.ytimg.com/vi/a2RA0vsZXf8/maxresdefault.jpg","width":1280,"height":720}},"channelTitle":"Kurt Hugo Schneider","categoryId":"10","liveBroadcastContent":"none","localized":{"title":"\"Just A Dream\" by Nelly - Sam Tsui & Christina Grimmie","description":"Check out our epic song with Coke Bottles! https://www.youtube.com/watch?v=ZzuRvzsNpTU\n\nHope you guys like this duet between Christina Grimmie and Sam Tsui on \"Just A Dream\" originally by Nelly!\n\nAnd if you don't know Christina, definitely check out her stuff and subscribe to her, because she rocks!!\nhttp://www.youtube.com/zeldaxlove64\n\nShare this on Facebook!  http://on.fb.me/JustADreamSamChristina\n\nWe just opened an online store with shirts, cd's and other cool stuff here:\nhttp://www.kurthugoschneider.com/store\n\n\n--------------\n\nLinks\n\nKURT SCHNEIDER\nFacebook- http://www.facebook.com/KurtHugoSchneider\nTwitter- http://www.twitter.com/KurtHSchneider\n\nSAM TSUI\nFacebook- http://www.facebook.com/SamTsuiMusic\nTwitter- http://www.twitter.com/SamuelTsui\n\n---------------\n\n'Just A Dream' (originally Performed By Nelly)\nWritten By: Cornell Haynes, Frank Romano, Jim Jonsin, James Scheffer, Richard Butler\nPublished By: Universal Music Publishing / EMI Music Publishing / Reach Global Inc."}},"statistics":{"viewCount":"96352554","likeCount":"804825","dislikeCount":"8957","favoriteCount":"0","commentCount":"132350"}}]}





Saturday 2 May 2015

How to set authorization header in Curl using zend framework

 How to set authorization header in Curl using zend framework

 How to set authorization header in Curl using Zend Framework
   $url ='www.domain.com/web-service-API';
  $config = array(
        'adapter' => 'Zend_Http_Client_Adapter_Curl',
        'curloptions' => array(CURLOPT_FOLLOWLOCATION => true,CURLOPT_SSL_VERIFYPEER =>FALSE),            
    );
    
    $client = new Zend_Http_Client($url, $config);
    //Set the Header value
    $client->setAuth('username', 'password!');
    
    $response = $client->request('GET'); 
    echo $response->getBody();



Set header (Name & Value) in curl using Zend Framework
$url ='www.domain.com/web-service-API';
  $config = array(
        'adapter' => 'Zend_Http_Client_Adapter_Curl',
        'curloptions' => array(CURLOPT_FOLLOWLOCATION => true,CURLOPT_SSL_VERIFYPEER =>FALSE),            
    );
    
    $client = new Zend_Http_Client($url, $config);
    //Set the Header value
    $client->setHeaders('HEADER-NAME', 'Header-Value');
    
    $response = $client->request('GET'); //Here you can set GET Method Also
    echo $response->getBody();   



Send the JSON Data in curl using Zend Framework
$url ='www.domain.com/web-service-API';
$json = json_encode(array('name'=>'Web','age'=>20));
  $config = array(
        'adapter' => 'Zend_Http_Client_Adapter_Curl',
        'curloptions' => array(CURLOPT_FOLLOWLOCATION => true,CURLOPT_SSL_VERIFYPEER =>FALSE),            
    );
    $response = $client->setRawData($json, 'application/json')->request('POST');
    echo $response->getBody();




Question: How to Set the username/password in CURL?
curl -X POST -u "USERNAME":"PASSWORD" --header "Content-Type: audio/flac" --header "Transfer-Encoding: chunked"  "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize" 




Question: How to pass binary User Authentication (Username/password) in CURL ?
$file='http://example.com/test/GM-qE2zq-1078-5525_360p.flac';
$jsonData = '';        
$config = array(
       'adapter' => 'Zend_Http_Client_Adapter_Curl',
       'curloptions' => array(CURLOPT_FOLLOWLOCATION => true,CURLOPT_SSL_VERIFYPEER =>FALSE),            
   );
    $url='https://stream.watsonplatform.net/speech-to-text/api/v1/recognize';
   $client = new Zend_Http_Client($url, $config);
   //Set the Header value
        $client->setHeaders('Content-Type', 'audio/flac');
    $client->setHeaders('Transfer-Encoding', 'chunked');            

   $client->setRawData(file_get_contents($file));
    //Set post method    
   $response = $client->request('POST'); 
   $jsonData= ($response->getBody());

Thursday 30 April 2015

How to delete the Zend Cache files from server


How to delete the zend cache files from server


How to create an object of Zend Cache
$cache = Zend_Cache::factory(
                        'Core', 'File', array(
                    'lifetime' => 3600 * 24 * 7, //cache is cleaned once a day                            
                    'automatic_serialization' => true
                        ), array('cache_dir' => APPLICATION_PATH . '/cache')
        );


Remove the cache by cache-id In this only one cache file will be removed from server.
$cache->remove('idToRemove');


Remove All cache files from Server. (When we delete files, caching automatic clear because we are using cache in files)
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);


Remove all outdated caching files.
$cache->clean(Zend_Cache::CLEANING_MODE_OLD);


Remove the cahe files which have two tags.
$cache->clean(
    Zend_Cache::CLEANING_MODE_MATCHING_TAG,
    array('matchingTag1', 'matchingTag2','matchingTag3') //Will remove which have matchingTag1 and matchingTag2 and matchingTag3
);


Remove all files which have not tag assign few tags.
$cache->clean(
    Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG,
    array('NotmatchingTag1', 'NotmatchingTag2') //Will Remove all the cahce which are NOT tagged with NotmatchingTag1 OR NotmatchingTag2
);


Remove all the cache files which have any tag (any of two or three).
$cache->clean(
    Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, //Will remove which have matchingTag1 OR matchingTag2 OR matchingTag3
     array('matchingTag1', 'matchingTag2','matchingTag3')
);








Monday 16 March 2015

How to send an email using Email Template in Zend Framework

How to send an email using Email Template in Zend Framework

Email functionalities in websites is very common and used in mostly in all web application. Whether it is registration process or Order detail, we need to send an email to your valuable client.

To send the email using Email Template follow the following steps
1. First collect all the data which you want to send in Email like first name, last name etc.
$emailTemplateData = array('fname'=>'Web Technology','lname'=>'Experts Notes');


2. Create a Folder with name emails, where you can put the email templates files.
Email template Location: application/views/scripts/emails


3. Create a template with name registration.phtml  for registration Email and add following contents.
First name:  echo $data['fname'];  
Last name:   echo $data['fname'];  
Folder Location: application/views/scripts/emails
Don't forget to add php scripts for php variable
Im just giving you an working code, you can add lot of variables as you need.


Add following code from where you want to send an email
$subject ='This is subject';
$view = new Zend_View();
$view->addScriptPath(APPLICATION_PATH . '/views/scripts/emails');
$view->data = $emailTemplateData; //$emailTemplateData must have the values which you are using in registration.phtml
$emailHtml = $view->render('registration.phtml');
$mail = new Zend_Mail();
$mail->setBodyHtml($emailHtml);
$mail->setSubject($subject);              
$mail->setFrom("support@example.com", "From domain.com");
$mail->send();


If you get an issue regarding this post, Please comment below. we will try to fix your problem.




Monday 2 March 2015

Get Youtube video-details and comments using PHP

Get Youtube video-details and comments using PHP

How to get youtube video detail in Zend (Response in JSON)
$uTubeVideoCode ='ryJReIcMGOs';        
        $jsonData='';
        try{            
            $client = new Zend_Http_Client("http://gdata.youtube.com/feeds/api/videos/{$uTubeVideoCode}?v=2&alt=json");
            $response = $client->request('GET');
            $jsonData = $response->getBody();
        
        }  catch (Exception $e){
            echo "Error:".$e->getMessage();
            
        }    
        echo $jsonData;die;

Output:
{"version":"1.0","encoding":"UTF-8","entry":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","xmlns$media":"http://search.yahoo.com/mrss/","gd$etag":"W/\"CkACQn47eCp7I2A9XRRWEkU.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs"},"published":{"$t":"2015-02-22T05:17:46.000Z"},"updated":{"$t":"2015-03-02T07:19:23.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#video"},{"scheme":"http://gdata.youtube.com/schemas/2007/categories.cat","term":"People","label":"People & Blogs"}],"title":{"$t":"ICC Cricket World Cup 2015 India Vs South Africa Game 13 Highlights - IND VS SA 22/02/15 2015"},"content":{"type":"application/x-shockwave-flash","src":"http://www.youtube.com/v/ryJReIcMGOs?version=3&f=videos&app=youtube_gdata"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs&feature=youtube_gdata"},{"rel":"http://gdata.youtube.com/schemas/2007#video.related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/related?v=2"},{"rel":"http://gdata.youtube.com/schemas/2007#mobile","type":"text/html","href":"http://m.youtube.com/details?v=ryJReIcMGOs"},{"rel":"http://gdata.youtube.com/schemas/2007#uploader","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/ZBJOTQ3A-HYLRmpYm4hDeA?v=2"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"}],"author":[{"name":{"$t":"SGZ Cricket"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/SGZCricket"},"yt$userId":{"$t":"ZBJOTQ3A-HYLRmpYm4hDeA"}}],"yt$accessControl":[{"action":"comment","permission":"allowed"},{"action":"commentVote","permission":"allowed"},{"action":"videoRespond","permission":"moderated"},{"action":"rate","permission":"allowed"},{"action":"embed","permission":"allowed"},{"action":"list","permission":"allowed"},{"action":"autoPlay","permission":"allowed"},{"action":"syndicate","permission":"allowed"}],"gd$comments":{"gd$feedLink":{"rel":"http://gdata.youtube.com/schemas/2007#comments","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments?v=2","countHint":32}},"yt$hd":{},"media$group":{"media$category":[{"$t":"People","label":"People & Blogs","scheme":"http://gdata.youtube.com/schemas/2007/categories.cat"}],"media$content":[{"url":"http://www.youtube.com/v/ryJReIcMGOs?version=3&f=videos&app=youtube_gdata","type":"application/x-shockwave-flash","medium":"video","isDefault":"true","expression":"full","duration":1544,"yt$format":5},{"url":"rtsp://r4---sn-a5m7zu7s.c.youtube.com/CiILENy73wIaGQnrGAyHeFEirxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":1544,"yt$format":1},{"url":"rtsp://r4---sn-a5m7zu7s.c.youtube.com/CiILENy73wIaGQnrGAyHeFEirxMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":1544,"yt$format":6}],"media$credit":[{"$t":"sgzcricket","role":"uploader","scheme":"urn:youtube","yt$display":"SGZ Cricket","yt$type":"partner"}],"media$description":{"$t":"ICC Cricket World Cup 2015 India Vs South Africa Game 13 Highlights - IND VS SA 22/02/15 2015\n\nICC Cricket World Cup 2015 India Vs Pakistan Game 4 Highlights - IND VS PAK 15/2/15\n\nICC Cricket World Cup 2015 India Vs South Africa\nICC Cricket World Cup 2015 India Vs South Africa 2/22/15\nICC Cricket World Cup 2015 India Vs South Africa 22 February 2015\n\nSubscribe For More Videos : https://www.youtube.com/user/SGZCricket\nGoogle + : https://plus.google.com/u/0/b/1093080...\n\nExtra Tag : ICC Cricket World Cup 2015 India Vs South Africa 2/22/15 ICC Cricket World Cup 2015 India Vs South Africa 2/22/15 2015 ICC Cricket World Cup 2015 India Vs South Africa 2/22/15 Full Match ICC Cricket World Cup 2015 India Vs South Africa 2/22/15 Highlights ICC Cricket World Cup 2015 India Vs South Africa 02/22/15 Full Results","type":"plain"},"media$keywords":{},"media$license":{"$t":"youtube","type":"text/html","href":"http://www.youtube.com/t/terms"},"media$player":{"url":"http://www.youtube.com/watch?v=ryJReIcMGOs&feature=youtube_gdata_player"},"media$thumbnail":[{"url":"http://i.ytimg.com/vi/ryJReIcMGOs/default.jpg","height":90,"width":120,"time":"00:12:52","yt$name":"default"},{"url":"http://i.ytimg.com/vi/ryJReIcMGOs/mqdefault.jpg","height":180,"width":320,"yt$name":"mqdefault"},{"url":"http://i.ytimg.com/vi/ryJReIcMGOs/hqdefault.jpg","height":360,"width":480,"yt$name":"hqdefault"},{"url":"http://i.ytimg.com/vi/ryJReIcMGOs/sddefault.jpg","height":480,"width":640,"yt$name":"sddefault"},{"url":"http://i.ytimg.com/vi/ryJReIcMGOs/1.jpg","height":90,"width":120,"time":"00:06:26","yt$name":"start"},{"url":"http://i.ytimg.com/vi/ryJReIcMGOs/2.jpg","height":90,"width":120,"time":"00:12:52","yt$name":"middle"},{"url":"http://i.ytimg.com/vi/ryJReIcMGOs/3.jpg","height":90,"width":120,"time":"00:19:18","yt$name":"end"}],"media$title":{"$t":"ICC Cricket World Cup 2015 India Vs South Africa Game 13 Highlights - IND VS SA 22/02/15 2015","type":"plain"},"yt$aspectRatio":{"$t":"widescreen"},"yt$duration":{"seconds":"1544"},"yt$uploaded":{"$t":"2015-02-22T05:17:46.000Z"},"yt$uploaderId":{"$t":"UCZBJOTQ3A-HYLRmpYm4hDeA"},"yt$videoid":{"$t":"ryJReIcMGOs"}},"gd$rating":{"average":1.6350245,"max":5,"min":1,"numRaters":1222,"rel":"http://schemas.google.com/g/2005#overall"},"yt$statistics":{"favoriteCount":"0","viewCount":"397572"},"yt$rating":{"numDislikes":"1028","numLikes":"194"}}}


How to get youtube video comments in Zend(Response in JSON)
        $uTubeVideoCode ='ryJReIcMGOs';        
        $jsonData='';
        try{            
            $client = new Zend_Http_Client("http://gdata.youtube.com/feeds/api/videos/{$uTubeVideoCode}/comments?v=2&alt=json");
            $response = $client->request('GET');
            $jsonData = $response->getBody();
        
        }  catch (Exception $e){
            echo "Error:".$e->getMessage();
            
        } 
echo $jsonData;  

Output:

{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$openSearch":"http://a9.com/-/spec/opensearch/1.1/","xmlns$yt":"http://gdata.youtube.com/schemas/2007","gd$etag":"W/\"CUYAQ3kzfCp7I2A9XRRWEkU.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comments"},"updated":{"$t":"2015-03-02T07:59:02.784Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"logo":{"$t":"http://www.gstatic.com/youtube/img/logo.png"},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments?v=2"},{"rel":"http://schemas.google.com/g/2005#batch","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/batch?v=2"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments?alt=json&max-results=25&v=2"},{"rel":"service","type":"application/atomsvc+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments?alt=atom-service&v=2"}],"author":[{"name":{"$t":"YouTube"},"uri":{"$t":"http://www.youtube.com/"}}],"generator":{"$t":"YouTube data API","version":"2.1","uri":"http://gdata.youtube.com"},"openSearch$totalResults":{"$t":21},"openSearch$itemsPerPage":{"$t":25},"entry":[{"gd$etag":"W/\"AkQDRX47eCp7I2A9XRRXFk0.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z13yynd4ssvaubg4n04cf3sytyaijddqwkc0k"},"published":{"$t":"2015-02-22T12:32:54.000Z"},"updated":{"$t":"2015-02-22T12:32:54.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"woooooooooooooooow\ufeff"},"content":{"$t":"woooooooooooooooow\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z13yynd4ssvaubg4n04cf3sytyaijddqwkc0k?v=2"}],"author":[{"name":{"$t":"Rujul Deshpande"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/lIx3u1pJAyoxSMT2YAoEjg"},"yt$userId":{"$t":"lIx3u1pJAyoxSMT2YAoEjg"}}],"yt$channelId":{"$t":"UClIx3u1pJAyoxSMT2YAoEjg"},"yt$googlePlusUserId":{"$t":"102896019321279244010"},"yt$replyCount":{"$t":1},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"C04NRH47eCp7I2A9XRRXFko.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z12oh5xbdqmmtdgii04ce33x5xz1xz3yrag"},"published":{"$t":"2015-02-23T06:13:15.000Z"},"updated":{"$t":"2015-02-23T06:13:15.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"can someone tell me ..."},"content":{"$t":"can someone tell me which game is this???\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z12oh5xbdqmmtdgii04ce33x5xz1xz3yrag?v=2"}],"author":[{"name":{"$t":"sajan sebastian"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/xzNmG-CxBF8AkMEtmtaCOw"},"yt$userId":{"$t":"xzNmG-CxBF8AkMEtmtaCOw"}}],"yt$channelId":{"$t":"UCxzNmG-CxBF8AkMEtmtaCOw"},"yt$googlePlusUserId":{"$t":"116346366931114012924"},"yt$replyCount":{"$t":1},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"D0IDQn47eCp7I2A9XRRXF0s.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z13hexfyzsigv5fd322qez1xupbbyvnee"},"published":{"$t":"2015-02-24T08:12:53.000Z"},"updated":{"$t":"2015-02-24T08:12:53.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"SGZ cricket..... ..."},"content":{"$t":"SGZ cricket..... grow up...\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z13hexfyzsigv5fd322qez1xupbbyvnee?v=2"}],"author":[{"name":{"$t":"Roshan More"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/mZCY2FMCPkNn8RdNlPf0ww"},"yt$userId":{"$t":"mZCY2FMCPkNn8RdNlPf0ww"}}],"yt$channelId":{"$t":"UCmZCY2FMCPkNn8RdNlPf0ww"},"yt$googlePlusUserId":{"$t":"101759163693693799937"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"AkYFQX47eCp7I2A9XRRWEE8.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z12yf5libtipzjki104cenrhvobhyftj2lk0k"},"published":{"$t":"2015-02-27T09:08:30.000Z"},"updated":{"$t":"2015-02-27T09:08:30.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"In this World cup ..."},"content":{"$t":"In this World cup each and every matches are interesting but only match \nschesule is not perfect ....\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z12yf5libtipzjki104cenrhvobhyftj2lk0k?v=2"}],"author":[{"name":{"$t":"Nikunj Goletar"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/Shu6BVmlTRMgS_HtaB9yzQ"},"yt$userId":{"$t":"Shu6BVmlTRMgS_HtaB9yzQ"}}],"yt$channelId":{"$t":"UCShu6BVmlTRMgS_HtaB9yzQ"},"yt$googlePlusUserId":{"$t":"108529240828297091468"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"DUYGQX47eCp7I2A9XRRXFk0.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z13juluxpmepddgrr04cjb2gnvvfhndyzp00k"},"published":{"$t":"2015-02-22T12:12:00.000Z"},"updated":{"$t":"2015-02-22T12:12:00.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"may i know the name ..."},"content":{"$t":"may i know the name of the game\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z13juluxpmepddgrr04cjb2gnvvfhndyzp00k?v=2"}],"author":[{"name":{"$t":"Gopinath V"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/tamilanxxx"},"yt$userId":{"$t":"9Qu8ceBfkJ9txoCO3k3ENw"}}],"yt$channelId":{"$t":"UC9Qu8ceBfkJ9txoCO3k3ENw"},"yt$googlePlusUserId":{"$t":"115360643619137243306"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"CUMBRH47eCp7I2A9XRRWEE4.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z13oyzgwvlroujxzu04cjjryjpyzwnmil54"},"published":{"$t":"2015-02-27T10:37:35.000Z"},"updated":{"$t":"2015-02-27T10:37:35.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"woooooooooooooooow\ufeff"},"content":{"$t":"woooooooooooooooow\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z13oyzgwvlroujxzu04cjjryjpyzwnmil54?v=2"}],"author":[{"name":{"$t":"Husnain shah"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/__NO_YOUTUBE_ACCOUNT__"},"yt$userId":{"$t":"__NO_YOUTUBE_ACCOUNT__"}}],"yt$channelId":{"$t":"UC__NO_YOUTUBE_ACCOUNT__"},"yt$googlePlusUserId":{"$t":"113607893143655172508"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"C0MDSX47eCp7I2A9XRRWEko.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z13mfpo41z3jebh2v22ggr5xtuqvyn2eo"},"published":{"$t":"2015-03-02T04:44:38.000Z"},"updated":{"$t":"2015-03-02T04:44:38.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"congrates\ufeff"},"content":{"$t":"congrates\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z13mfpo41z3jebh2v22ggr5xtuqvyn2eo?v=2"}],"author":[{"name":{"$t":"Amol Awasthi"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/THBPSc-ik_m440Djkhe0ew"},"yt$userId":{"$t":"THBPSc-ik_m440Djkhe0ew"}}],"yt$channelId":{"$t":"UCTHBPSc-ik_m440Djkhe0ew"},"yt$googlePlusUserId":{"$t":"118383318670254507980"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"DUMERn47eCp7I2A9XRRWEE8.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z13bs11qzp2kjvpsj22ecvjb5ouvh1ilb"},"published":{"$t":"2015-02-27T08:56:47.000Z"},"updated":{"$t":"2015-02-27T08:56:47.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"haha you are the ..."},"content":{"$t":"haha you are the world fellow ever\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z13bs11qzp2kjvpsj22ecvjb5ouvh1ilb?v=2"}],"author":[{"name":{"$t":"nani98663"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/nani98663"},"yt$userId":{"$t":"_oMue9jTfGX75AQUxeceiw"}}],"yt$channelId":{"$t":"UC_oMue9jTfGX75AQUxeceiw"},"yt$googlePlusUserId":{"$t":"115292334965355156920"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"DkYMQX47eCp7I2A9XRRXGEQ.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z12th1ditzvedbxsp22kxxlzeuucfbrcw"},"published":{"$t":"2015-02-25T19:56:20.000Z"},"updated":{"$t":"2015-02-25T19:56:20.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"seriously grow up ..."},"content":{"$t":"seriously grow up man\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z12th1ditzvedbxsp22kxxlzeuucfbrcw?v=2"}],"author":[{"name":{"$t":"Ishan Shinde"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/5nefuBa-wS5dlh9mthIsQQ"},"yt$userId":{"$t":"5nefuBa-wS5dlh9mthIsQQ"}}],"yt$channelId":{"$t":"UC5nefuBa-wS5dlh9mthIsQQ"},"yt$googlePlusUserId":{"$t":"115372824146721655757"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"A0YNSX47eCp7I2A9XRRXF00.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z13pgp5yirr0wtxik04civwpimrcerapvek"},"published":{"$t":"2015-02-23T16:33:18.000Z"},"updated":{"$t":"2015-02-23T16:33:18.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"hell no.... how ..."},"content":{"$t":"hell no.... how interesting....lol\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z13pgp5yirr0wtxik04civwpimrcerapvek?v=2"}],"author":[{"name":{"$t":"Darshan Jain"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/TmQQ8VHwustduwHXiLowWg"},"yt$userId":{"$t":"TmQQ8VHwustduwHXiLowWg"}}],"yt$channelId":{"$t":"UCTmQQ8VHwustduwHXiLowWg"},"yt$googlePlusUserId":{"$t":"116504884552174068967"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"DEMER347eCp7I2A9XRRXGEQ.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z13utrm4zyjgwd20n22tfnzqzvuehh5lc"},"published":{"$t":"2015-02-25T20:33:26.000Z"},"updated":{"$t":"2015-02-25T20:33:26.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"Grow up friend\ufeff"},"content":{"$t":"Grow up friend\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z13utrm4zyjgwd20n22tfnzqzvuehh5lc?v=2"}],"author":[{"name":{"$t":"abhijit kulkarni"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/abhijit0727"},"yt$userId":{"$t":"NWvmyhNFs1B8ljeaQXES1A"}}],"yt$channelId":{"$t":"UCNWvmyhNFs1B8ljeaQXES1A"},"yt$googlePlusUserId":{"$t":"105890333904958496583"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"D04DQ347eCp7I2A9XRRXF08.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z12wxpvrlofxc5s0w23ownp4doe4wrx4r04"},"published":{"$t":"2015-02-23T21:12:52.000Z"},"updated":{"$t":"2015-02-23T21:12:52.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"wow the crowd sucks ..."},"content":{"$t":"wow the crowd sucks in this game\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z12wxpvrlofxc5s0w23ownp4doe4wrx4r04?v=2"}],"author":[{"name":{"$t":"Mehul Shukla"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/mehulshukla04"},"yt$userId":{"$t":"xu8mQo6LHTGfYAG-j7mNug"}}],"yt$channelId":{"$t":"UCxu8mQo6LHTGfYAG-j7mNug"},"yt$googlePlusUserId":{"$t":"105925848190989770553"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"A08BQ347eCp7I2A9XRRXF0g.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z12wf3irhvr5sbbjq04ccx4rtz24yveq25k"},"published":{"$t":"2015-02-24T06:37:32.000Z"},"updated":{"$t":"2015-02-24T06:37:32.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"can u tell the name ..."},"content":{"$t":"can u tell the name of the game plss??????\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z12wf3irhvr5sbbjq04ccx4rtz24yveq25k?v=2"}],"author":[{"name":{"$t":"nikhil kulal"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/HZacepyCMUAS5AzaKPImwA"},"yt$userId":{"$t":"HZacepyCMUAS5AzaKPImwA"}}],"yt$channelId":{"$t":"UCHZacepyCMUAS5AzaKPImwA"},"yt$googlePlusUserId":{"$t":"103284323473829074041"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"D04FRX47eCp7I2A9XRRXFkQ.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z125irwomybbexbvj23dwxqgbtbdyf0nc"},"published":{"$t":"2015-02-23T12:51:54.000Z"},"updated":{"$t":"2015-02-23T12:51:54.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"woow vata game\ufeff"},"content":{"$t":"woow vata game\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z125irwomybbexbvj23dwxqgbtbdyf0nc?v=2"}],"author":[{"name":{"$t":"pradeep appu"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/7j-ZZrFk6CylNMihVsV1vQ"},"yt$userId":{"$t":"7j-ZZrFk6CylNMihVsV1vQ"}}],"yt$channelId":{"$t":"UC7j-ZZrFk6CylNMihVsV1vQ"},"yt$googlePlusUserId":{"$t":"116605829416262485807"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"AkUNQn47eCp7I2A9XRRWEEo.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z121c51wuquciznns230yxnorkb2x34ai04"},"published":{"$t":"2015-02-27T23:04:53.000Z"},"updated":{"$t":"2015-02-27T23:04:53.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"superhero..indian . ..."},"content":{"$t":"superhero..indian ..jai ho\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z121c51wuquciznns230yxnorkb2x34ai04?v=2"}],"author":[{"name":{"$t":"chupbhosari terabaap"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/80XYP3ohlonHxFjyJxMg9w"},"yt$userId":{"$t":"80XYP3ohlonHxFjyJxMg9w"}}],"yt$channelId":{"$t":"UC80XYP3ohlonHxFjyJxMg9w"},"yt$googlePlusUserId":{"$t":"107946096902915779887"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"AkEGR347eCp7I2A9XRRXFkQ.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z13scpvijxithh0lm23dxpa5vkzsw50a304"},"published":{"$t":"2015-02-23T13:37:06.000Z"},"updated":{"$t":"2015-02-23T13:37:06.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"good\ufeff"},"content":{"$t":"good\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z13scpvijxithh0lm23dxpa5vkzsw50a304?v=2"}],"author":[{"name":{"$t":"Maha Linagam"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/mali4991"},"yt$userId":{"$t":"4NyMEDI3PVTVEM9Fga-K5Q"}}],"yt$channelId":{"$t":"UC4NyMEDI3PVTVEM9Fga-K5Q"},"yt$googlePlusUserId":{"$t":"103431499595674948971"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"DUAFRH47eCp7I2A9XRRXF00.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z12nxdegiqzecxljo04chvn4dkzmuvwgdr00k"},"published":{"$t":"2015-02-23T16:08:35.000Z"},"updated":{"$t":"2015-02-23T16:08:35.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"dafuq is this???\ufeff"},"content":{"$t":"dafuq is this???\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z12nxdegiqzecxljo04chvn4dkzmuvwgdr00k?v=2"}],"author":[{"name":{"$t":"Katherine May"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/Vvt17yrrm4cwZT5HakoHFw"},"yt$userId":{"$t":"Vvt17yrrm4cwZT5HakoHFw"}}],"yt$channelId":{"$t":"UCVvt17yrrm4cwZT5HakoHFw"},"yt$googlePlusUserId":{"$t":"105114308315934876966"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"CkIDSH47eCp7I2A9XRRXGUg.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z12detpbmozjc5dms23csd4rkyvgsvnok04"},"published":{"$t":"2015-02-26T11:36:19.000Z"},"updated":{"$t":"2015-02-26T11:36:19.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":""},"content":{"$t":""},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z12detpbmozjc5dms23csd4rkyvgsvnok04?v=2"}],"author":[{"name":{"$t":"Ashokkumar T"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/3kFgr6i5Ugr7aIYEZvU-Iw"},"yt$userId":{"$t":"3kFgr6i5Ugr7aIYEZvU-Iw"}}],"yt$channelId":{"$t":"UC3kFgr6i5Ugr7aIYEZvU-Iw"},"yt$googlePlusUserId":{"$t":"101665337513199560569"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}},{"gd$etag":"W/\"C0ANQn47eCp7I2A9XRRWEUQ.\"","id":{"$t":"tag:youtube.com,2008:video:ryJReIcMGOs:comment:z12uy31y3weyelzop04cgnoyloukhpvrcrs0k"},"published":{"$t":"2015-03-01T06:36:33.000Z"},"updated":{"$t":"2015-03-01T06:36:33.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#comment"}],"title":{"$t":"New inspiring song ..."},"content":{"$t":"New inspiring song for team india to win the world cup\nhttps://www.youtube.com/watch?v=vxNf1m2SiY0\ufeff"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs?v=2"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=ryJReIcMGOs"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/ryJReIcMGOs/comments/z12uy31y3weyelzop04cgnoyloukhpvrcrs0k?v=2"}],"author":[{"name":{"$t":"Kumar K"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/X0WlKnTMzGDgVDZ4TmWujQ"},"yt$userId":{"$t":"X0WlKnTMzGDgVDZ4TmWujQ"}}],"yt$channelId":{"$t":"UCX0WlKnTMzGDgVDZ4TmWujQ"},"yt$googlePlusUserId":{"$t":"116638980038801195984"},"yt$replyCount":{"$t":0},"yt$videoid":{"$t":"ryJReIcMGOs"}}]}}


Best Related Posts are Following:
1. How to send Email in Zend Framework - HTML Email
2. Send Email from Gmail SMTP using Zend Framework
3. Google trends api php - How to get hot trends
4. Multiple column ordering in Zend Framework
5. Current time zone for a city- Free API
6. Zend Gdata Youtube API - Search Video - View Video Detail
7. Download Videos from Amazon S3 - PHP
8. How to set Cron in Zend Framework
9. Zend Cache Tutorial - Zend Framework 1.12
10. Zend Framework Interview Questions and Answers for Experienced

Thursday 19 February 2015

How to send Attachment in Email in zend framework1 - Send PDF File

How to send Attachment in Email in zend framework1 - Send PDF File

Sending an attachment in Email is very easy in zend framework. Attachmnet can be PDF file, image file, text and excel file etc. For Different type of attachment have different types of mime type. For example pdf mime type is "application/pdf" where gif image mime type is "image/gif".

In E-commerce website, when an order is placed by customer on the online website. Customer get the order detail in form of Order PDF File, So that he can keep offline record too.


Following code snippet is for How to attach a PDF file in Email using Zend Framework.
 
  /** Must fill Following detail * */
        $emailTo = 'receipts@no-spam.ws';
        $emailToName = 'receipts Name';
        /** Must fill Following detail * */
        $emailSubject = 'This is subject';
        $emailBody = 'This is HTML Email Body';
        $fromEmail = 'fromemail@no-spam.ws';
        try {
            $config = array(
                'ssl' => 'tls',
                'auth' => 'login',
                'username' => 'SMTP_USERNAME',
                'password' => 'SMTP_PASSWORD'
            );
            $transport = new Zend_Mail_Transport_Smtp('SMTP_HOST', $config);

            $mail = new Zend_Mail();
            $mail->setBodyHtml($emailBody);
            $mail->setFrom($fromEmail);
            $mail->addTo($emailTo, $emailToName);
            $mail->setSubject($emailSubject);
            
            /**PDF Add Attachment **/
            $attachment = new Zend_Mime_Part('path to pdf file');
            $attachment->type        = 'application/pdf';
            $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
            $attachment->encoding = Zend_Mime::ENCODING_BASE64;
            $attachment->filename    = 'order.pdf';
            $mail->addAttachment($attachment);
            /** Add Attachment **/            

            if ($mail->send($transport)) {
                echo 'Sent successfully';
            } else {
                echo 'unable to send email';
            }
        } catch (Exception $e) {
            echo $e->getMessage();
        }



Different Types of Attachment 



Monday 9 February 2015

How to send Email in Zend Framework - HTML Email

How to send Email in Zend Framework - HTML Email


In websites, We send email to our clients for Following:
- Registration Email
- Forget Password
- Change Password
- Notification Email
- Newsletter
- Order completed
- Order In transist
- Order deliver Successfully


Following code, Which can be used to send email in Zend-Framework (HTML EMAIL).
 
/** Must fill Following detail * */
        $emailTo = 'receipts@no-spam.ws';
        $emailToName = 'receipts Name';
        /** Must fill Following detail * */
        $emailSubject = 'This is subject';
        $emailBody = 'This is HTML Email Body';
        $fromEmail = 'fromemail@no-spam.ws';
        try {
            $config = array(
                'ssl' => 'tls',
                'auth' => 'login',
                'username' => 'SMTP_USERNAME',
                'password' => 'SMTP_PASSWORD'
            );
            $transport = new Zend_Mail_Transport_Smtp('SMTP_HOST', $config);

            $mail = new Zend_Mail();
            $mail->setBodyHtml($emailBody);
            $mail->setFrom($fromEmail);
            $mail->addTo($emailTo, $emailToName);
            $mail->setSubject($emailSubject);
            if ($mail->send($transport)) {
                echo 'Sent successfully';
            } else {
                echo 'unable to send email';
            }
        } catch (Exception $e) {
            echo $e->getMessage();
        }

Above code is For html email, You can use html tags like bold, italic, table etc for sending rich text email.


Monday 2 February 2015

Send Email from Gmail SMTP using Zend Framework

Send Email from Gmail SMTP using Zend Framework

In Website we need to send email on Registration, Forget , Order email to our Clients/Customer.
We want email should be deliver timely in inbox folder not in junk/spam folder.
For this we have to use SMTP Server.

GMAIL SMTP Server is free to use, if you have valid Gmail account.

Just the following code to send email from your Gmail Account.
/** Must fill Following detail * */
$yourGmailAccountUsername = 'youremail@gmail.com';
$yourGmailAccountPassword = '********';
$emailTo = 'arun.compute@gmail.com';
$emailToName = 'receiptsName';
/** Must fill Following detail * */

/** Optional Detail * */
$emailBody = 'This is body text';
$emailSubject = 'This is subject';
/** Optional Detail * */

try {
    $config = array('ssl' => 'tls',
        'auth' => 'login',
        'username' => $yourGmailAccountUsername,
        'password' => $yourGmailAccountPassword);

    $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);


    $mail = new Zend_Mail();

    $mail->setBodyHtml($emailBody);
    $mail->setFrom($yourGmailAccountUsername);
    $mail->addTo($emailTo, $emailToName);
    $mail->setSubject($emailSubject);
    if ($mail->send($transport)) {
        echo 'Sent successfully';
    } else {
        echo 'unable to send email';
    }
} catch (Exception $e) {
    echo $e->getMessage();
}

If you get similar to following Error
Please log in via your web browser and then try again.
5.7.14 Please log in via your web browser and then try again. 5.7.14 Learn more at 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 fr13sm3613053pdb.81

If Yes,
whether you have "turned on 2-Step Verification" OR Google need Verification that you want to use your gmail as SMTP credential.
you can fix this in couple of minutes using below link:
https://support.google.com/mail/answer/78754

If any issue, please comment below in comment box: