1

Question

I cant seem to find any YouTube API documents on the new Zend Framework 2.0.2. Is there any external or extra downloads I need to do? All the tutorials are based on older versions of Zend!

Or should I just download an older version of Zend?


Answer

I'm giving this answer for anyone else that may need it in the future.

You will have to download Zend Framework 1.7.7. As the YouTube API uses the Gdata folder. On my research this is the only version that will support the YouTube API.

Hope this helps someone.

1 Answer 1

8

The GData API is available in ZF2, you just need to install the package that contains it.

You can find a list of available packages here.

If you are already using Composer for ZF2, simply add "zendframework/zendgdata": "2.0.*" to the list of pacakges in the require section and then run php composer.phar update to fetch the GData package and you can now begin using the GData classes.

If you aren't using Composer, here is how you can obtain the GData\YouTube library.

From a new directory, install Composer:

curl -s https://getcomposer.org/installer | php

Note: If you don't have cURL, just download the installer from the above URL and run php installer

Now that Composer is installed create a composer.json file with the following contents:

{
    "repositories": [
        {
            "type": "composer",
            "url": "http://packages.zendframework.com/"
        }
    ],
    "require": {
        "zendframework/zendgdata": "2.0.*"
    }
}

By adding the zendframework/zendgdata package to the require list, composer will download and install this package along with ZF2.

Now run the install:

php composer.phar install

You now have a copy of Zend Framework 2 and the GData package in the newly created vendor directory.

To test it, create test.php in the same directory as composer.json that looks like this:

<?php

require_once 'vendor/autoload.php';

$youtube = new ZendGData\YouTube();

var_dump($youtube);

The usage of the GData YouTube APIs in ZF2 are similar to in ZF1, but if you look in the vendor/zendframework/zendgdata/tests/ZendGData/ directory, you can see a number of tests which you can use as examples for getting started with the various ZF2 YouTube classes.

Hope that helps.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.