• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Cached Youtube API Client (CaYAC)
PostPosted: Fri Oct 31, 2008 12:21 am 
CaYAC is a plug-in that allows access of a users youtube feed via smarty. However, it doesn't use the RSS feed, but the latest uploads xml feed from the youtube api. Thus, there is plenty of information we get extra and can use for fancy stuff with extra smarty :)

Download here: http://dev.cmsmadesimple.org/projects/apiyoutubefeed/

Data structure:
Code:
n = integer

$videos [ n ] -> info -> id
$videos [ n ] -> info -> title
$videos [ n ] -> info -> description
$videos [ n ] -> info -> keywords
$videos [ n ] -> info -> views
$videos [ n ] -> info -> duration
$videos [ n ] -> info -> published
$videos [ n ] -> info -> updated
$videos [ n ] -> info -> rating

$videos [ n ] -> view -> media_content_url
$videos [ n ] -> view -> media_content_type
$videos [ n ] -> view -> pageurl

$videos [ n ] -> thumbnail_small -> width
$videos [ n ] -> thumbnail_small -> height
$videos [ n ] -> thumbnail_small -> url

$videos [ n ] -> thumbnail_large -> width
$videos [ n ] -> thumbnail_large -> height
$videos [ n ] -> thumbnail_large -> url

$videos [ n ] -> comments -> feedurl
$videos [ n ] -> comments -> count


You can call the tag as easy as {api_youtubefeed name="YOUTUBE USERNAME"}. If you don't supply a name, for experimental use, the feed from balcony tv (not affiliated, random pick ;) ) will be used. It features plenty of data.

Dates can optionally be formated using php strftime parameters. Cacheing max age can also be configured optionally.

The cache takes car that the server doesn't have to wait for the youtube server to reply each time a page is requested. Addiionally, only the fewest youtube user feeds will require to be reloaded more frequently than every 4 minutes (default). If you need a refresh before max age, clean cache via reg. admin panel. It also helps to deal with quota limitations.

For playing videos howver... you need to take of that on your own. The plug-in only provides data for further processing with smarty. But here is some info how to embed youtube with valid xhtml  in the wiki.

So, with this plug-in, you can do stuff like:
- User profile with latest videos
- Product TV on Company Site ("Will it blend?") with the newest episodes
- Youtube Video-Casts in Site einbinden

The help contains a sample code snippet to print out all variables (as a little kick-start).

Let me know what you think.

Enjoy
Nils


Top
  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Sat Jun 06, 2009 1:10 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Mar 13, 2007 7:10 pm
Posts: 26
Location: Wisconsin, USA/Bermuda
I installed the plugin for both youtube and twitter and got errors on both. Here is the error I got after installing the youtube plugin:

Fatal error: Call to undefined function: simplexml_load_file() in C:\Inetpub\vhosts\duncan7.ihostsites.net\httpdocs\plugins\function.api_youtubefeed.php on line 39

What do I need to change to get it working?

Thanks.

_________________
Websites at NINJA Speed!


Top
 Profile  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Sat Jun 06, 2009 5:41 pm 
Hi snatrott,

have you also copied the "nh_essentials" and placed the tag {nh_essentials} into you templates as well?

For Twitter, please use the plug-in from the API collection (which requires nh_essentials).

What CMS Version are you using and what is your PHP version? Can your installation access remote files?

Best
Nils


Top
  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Tue Jul 07, 2009 7:12 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Mar 13, 2007 7:10 pm
Posts: 26
Location: Wisconsin, USA/Bermuda
Sorry I didn't get back to you. I ended up going a different route with both YouTube videos and Twitter but I may attempt them again just so I know for sure how to get them working in case I need them in the future. I will let you know if I have problems with either one.

Thanks.

_________________
Websites at NINJA Speed!


Top
 Profile  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Tue Aug 25, 2009 3:22 pm 
Offline
Forum Members
Forum Members

Joined: Wed Apr 18, 2007 9:57 am
Posts: 70
I'm having the same problem, where do a put
Code:
{nh_essentials}
?

I have the latest CMSMS version 1.6.4 installed this is the error I get
Code:
Fatal error: Call to undefined function: simplexml_load_file() in /homepages/8/d266017000/htdocs/square one/plugins/function.api_youtubefeed.php on line 39


Any ideas how to make this work?

Thanks
Jane


Top
 Profile  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Wed Aug 26, 2009 11:25 am 
Where have you put it now? HAve you placed the php file into your plug-in folder?

Best
Nils


Top
  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Wed Aug 26, 2009 12:01 pm 
Offline
Forum Members
Forum Members

Joined: Wed Apr 18, 2007 9:57 am
Posts: 70
Hi Nils,

I have put the php file in my plugins folder and I have put {nh_essentials} in the head of my template. Is this correct?

Thanks
Jane


Top
 Profile  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)  [SOLVED]
PostPosted: Thu Jan 21, 2010 7:45 pm 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 217
Location: Nashville, USA
Hi,

I need to limit the results shown to be less than the default of 25.  Is there a way to do this using smarty functions or should I modify the (CaYAC) script?  I tried to use the newer function.nh_api_youtubesearch.php, but I need to display a specific youtube user and would need to modify this one to do that.  Any sugguestions?

thanks!! :)

_________________
--
LinkedIn.com
--
Internal Page 301 Redirect
--
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo


Top
 Profile  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Fri Jan 22, 2010 10:23 am 
Hi MWW,

you have two options. You can limit the output using Smarty and Section (http://www.smarty.net/manual/en/languag ... ection.php). This way, you could address the first 10 Videos for example.

Alternatively, you could change the script in line 108 to request fewer videos.

Change:
Code:

   // This is the XML Feed we want to get. The XML feed provides more info than the regular RSS
      $feed_url = "http://gdata.youtube.com/feeds/api/users/".$user_name."/uploads";



Into:

Code:

   // This is the XML Feed we want to get. The XML feed provides more info than the regular RSS
      $feed_url = "http://gdata.youtube.com/feeds/api/users/".$user_name."/uploads?max-results=4";



That should do the trick. Just adjust max-results to your personal preference.

Let me know if that solved your problem.

Best
Nils


Top
  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Fri Jan 22, 2010 6:24 pm 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 217
Location: Nashville, USA
Hi Nils,

Those are great suggestions - thank you!

I think I will change the code using ... uploads?max-results=4";

This is what I did yesterday which works really well, but changing the code will use less processing probably.
Code:
{api_youtubefeed name=youtube-user ttl=480}
   {counter assign=max print=0}
      {foreach from=$videos item=video}
      {counter}
      {if $max <= 2}
      <div class="video-feed">
         <p>
         <a class="external" title="{$video->info->description|truncate:80}" href="{$video->view->pageurl}">
         <img src="{$video->thumbnail_small->url}" alt="{$video->info->keywords}" width="100" height="75" align="left" /><strong>{$video->info->published|cms_date_format}—{$video->info->title}</strong></a>
         <br />{$video->info->description|truncate:120:"..."}</p>
      </div>
      <br class="clear" />
      {/if}
   {/foreach}


Thanks for providing this script to the cmsms community!!!

_________________
--
LinkedIn.com
--
Internal Page 301 Redirect
--
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo


Last edited by mww on Fri Jan 22, 2010 6:26 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Fri Feb 12, 2010 10:13 pm 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 217
Location: Nashville, USA
How would I implement the Smarty {section}{/section}?  I need to use the tag in more than one place so editing the tag script isn't an option for me right now.

I tried the following:

Code:
<div class="social-block-content">
{api_youtubefeed name=crcanney ttl=480}
{foreach from=$videos item=video}
   {section loop=$video name=video2 max=1}
   <p><a class="external" title="{$video->info->description|truncate:80}" href="{$video->view->pageurl}"><img src="{$video->thumbnail_small->url}" alt="{$video->info->keywords}" width="100" height="75" align="left" /><strong>{$video->info->published|cms_date_format}—{$video->info->title}</strong></a><br />{$video->info->description|truncate:120:"..."}</p>
   {/section}
{/foreach}
</div>


and

Code:
<div class="social-block-content">
{api_youtubefeed name=crcanney ttl=480}
{section loop=$videos name=video max=1}
   <p><a class="external" title="{$video->info->description|truncate:80}" href="{$video->view->pageurl}"><img src="{$video->thumbnail_small->url}" alt="{$video->info->keywords}" width="100" height="75" align="left" /><strong>{$video->info->published|cms_date_format}—{$video->info->title}</strong></a><br />{$video->info->description|truncate:120:"..."}</p>
{/section}
</div>

_________________
--
LinkedIn.com
--
Internal Page 301 Redirect
--
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo


Top
 Profile  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Tue Feb 16, 2010 5:49 pm 
Do you want to call different user feeds on the same page or just place the videos into different locations (e.g. not a "classical" list of videos)?

You could do something like:

Code:

$video[0]->view->pageurl and
$video[1]->view->pageurl ...
$video[n]->view->pageurl ...



Would that solve your question?

Best
Nils


Top
  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Wed Feb 17, 2010 12:31 am 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 217
Location: Nashville, USA
Quote:
Do you want to call different user feeds on the same page or just place the videos into different locations (e.g. not a "classical" list of videos)?

The website needed a feed list of current videos and it also needs to show the most recent video. Same author for both and they are on the same page in different locations.

For now I used Simplepie for the second feed.


I edited CaYAC so it can take a max="" parameter (Thanks!)

Code:
   // Select the max returned results wanted
      if ($params['max'] != '') {
         $max_results = '?max-results='.$params['max'];
      } else {
         $max_results = '';
      }

$feed_url = "http://gdata.youtube.com/feeds/api/users/".$user_name."/uploads".$max_results;


_________________
--
LinkedIn.com
--
Internal Page 301 Redirect
--
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo


Top
 Profile  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Thu Feb 18, 2010 7:47 pm 
Hi MWW,

sorry for the late reply, have been working out of town the last weeks. I'm still not quite sure what you try to accomplish. Though I may be because I'm a little sleepy right now and don't get it.

I understood the following:

You have a video embedded of user XYZ and below you feature a list of the other newest videos of that person (in form of links)? In that case, the best way to go ahead would indeed be the section approach (I think). Without updating the script itself, you could do something like the following.

Code:

{assign var=video_count value=$videos|@count}
{if $video_count > 0}
   <h1>The Single Video</h1>
   {section name=my_counter start=0 loop=1 step=1}
      {$videos[$my_counter]->view->pageurl}...
      ...
      ...
   {/section}
{/if}

{if $video_count > 1}
   <h1>The Video-List</h1>
   <ul>
   {section name=my_counter start=1 loop=$video_count step=1}
      <li>{$videos[$my_counter]->view->pageurl}...</li>
   {/section}
   </ul>
{/if}



I haven't run this smarty code but think this could work, at least it might provide you with some inspiration ;D
Let me know if that worked.

Best
Nils


Top
  
 
 Post subject: Re: Cached Youtube API Client (CaYAC)
PostPosted: Fri Feb 19, 2010 4:33 pm 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 217
Location: Nashville, USA
Hi,
Quote:
You have a video embedded of user XYZ and below you feature a list of the other newest videos of that person (in form of links)? In that case, the best way to go ahead would indeed be the section approach (I think).

Yes, that is what the site needs.

I tried the section suggestion and couldn't get it to work. I tried a few variations and tried using a section without a count, but still couldn't figure it out.

_________________
--
LinkedIn.com
--
Internal Page 301 Redirect
--
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: eddyndm


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner