Zend Framework 2.0.2 YouTube API

余生长醉 提交于 2019-12-09 14:10:22

问题


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:


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.



来源:https://stackoverflow.com/questions/13007510/zend-framework-2-0-2-youtube-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!