Category

Zend Framework

19 APR

Using Zencoder with Zend Framework

Zencoder is an API-based online video and audio encoding service. Zencoder converts videos from your website, application, or video library into formats that are compatible with web playback, mobile phone, or any other device you need to support. Zencoder have friendly API and php library. We can use this library with Zend Framework after some modifications. Click here to download modified library.

Read more


4 MAR

Zend_Gdata_Youtube and disallowing commenting/embedding of video

Even in the latest ZF stable release 1.11.4 there is still no support of new Youtube API accessControl element. The framework is still using yt:noembed option and has no support for disallowing commenting at all. As I tried yt:noembed – it wasn’t working, so we need to add support to ZF of this feature. First we need to understand how Youtube feed needs to be formed in order to prevent commenting and/or embedding. It’s done using element and its options.

and

Since ZF Gdata API has support of noembed option it has the class and methods forming RSS DOM that check for noembed element and append it where necessary, but there is no nocomment support, so we need the same extension class + DOM append this element. So first let’s create Extension_NoComment class similar to other extension classes:


/**
 * @see Zend_Gdata_Extension
 */
require_once 'Zend/Gdata/Extension.php';


class Zend_Gdata_YouTube_Extension_NoComment extends Zend_Gdata_Extension
{

    protected $_rootNamespace = 'yt';
    protected $_rootElement = 'accessControl';
    protected $_extensionAttributes = array(
                                            array('name'  => 'permission',
                                                  'value' => 'denied'),
                                            array('name'  => 'action',
                                                  'value' => 'comment'));

 
    public function __construct($enabled = null)
    {
        $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
        parent::__construct();
    }

}

Read more


21 FEB

Website Screen scrapping using Zend Framework

ZF is a component-based framework, so we can only use some of its packages for a specific task. For example, if we don’t need to build a site and don’t need MVC, dispatchers, routers and so on, we can include only necessary packages for the task.

Assume we need to build a screen-scrapper for a site or group of sites. We’d need Zend_Dom_Query with its convenient xpath and css query methods and Zend_Json since many sites interact in AJAX using JSON.

So, we start with forming the packages we only need. Since we use ZF classes and they in turn load their base classes, so we need Zend_Loader. which will register its own autoload function. Here is all we need for the task:
Read more


21 FEB

S/MIME email encryption/signing using Zend_Mail

Recently I wrote a class for ZF that one can use as a convenient tool for signing and/or encrypting email documents. The tricky thing was that MS Outlook Express did not want to treat it as Signed and Encrypted message unless you add “\n” to the end of the message , that was hard to find and I had to only experiment as there are almost no good sources in the Internet about this problem. The issue is reported here: http://ua.php.net/manual/en/function.op … .php#36038
except that instead of beginning of a message I should have placed it at the end. Here is the example usage of the class:

Read more


21 FEB

PAdES (PKCS11) and Zend_Pdf

Similar to my last post about Zend_Mail S/MIME class, this one allows to digitally sign and even add TSA (timestamping) support to your PDF documents generated using Zend_Pdf. There is a standalone ASN1 parser included that can be used for other projects that require ASN1 data interchange. See http://en.wikipedia.org/wiki/PAdEShttp://www.ietf.org/rfc/rfc3161.txt for reference. The challenge was to add the BytesRange element with right byte bounds of the signed document. How to use it:

Read more