Saturday 15 January 2011

Delete video from Youtube with Zend Youtube API

A few weeks ago I was faced with problem of removing video from Youtube. Zend Youtube API was used for this purposes.

As the documentation describes, to delete a video it is necessary to get the video uploading channel for authenticated user and than invoke the delete method on the Zend_Gdata_YouTube service object, passing in the VideoEntry object that is being deleted.

The documentation and different web-dev blogs describes the process of the deleting video from Youtube using following code:
$videoEntryToDelete = $yt->getVideoEntry($videoId);
$yt->delete($videoEntryToDelete);
Looks simple, but the code example doesn't work. Method getVideoEntry doesn't provide the access to full control of the video.

To delete the video I used the method getFullVideoEntry() to get the videoEntry. The code example show how it can be done:
$videoEntry = $yt->getFullVideoEntry($videoId); 
$yt->delete($videoEntry) 

Thursday 6 January 2011

Change iframe src attribute in Facebook applications

Sometimes it is necessary to change source of the iframe on facebook applications dynamically. In Facebook applications iframe can be created only using tag "fb:iframe" and Facebook doesn't allow access to iframe attributes. Of course we can create a set of fb:js string variables for all cases that we need. But it is not very good solution.

One of the solutions that can be used looks as follows.

At first create iframe using fbml:
<fb:js-string var="iframe_element">
  <fb:iframe id="fb-iframe" src="http://your.iframe.location" />
</fb:js-string>

Than we should have an html element that will be a container for iframe:
<div id="iframe-block"> </div>
Next step is to display iframe. This can be done using fbml method setInnerFBML:
document.getElementById('iframe-block').setInnerFBML(iframe_element);
After this we can get access to iframe attributes.
document.getElementById('view-iframe-element').setSrc('http://your-new-url');
So, the only way to change the src of iframe that I could find is to display the iframe and the change it attribute src.