当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Gdata_YouTube::setHttpClient方法代码示例

本文整理汇总了PHP中Zend_Gdata_YouTube::setHttpClient方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube::setHttpClient方法的具体用法?PHP Zend_Gdata_YouTube::setHttpClient怎么用?PHP Zend_Gdata_YouTube::setHttpClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Gdata_YouTube的用法示例。


在下文中一共展示了Zend_Gdata_YouTube::setHttpClient方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: module_last_youtube_playlist_videos

/**
 * @param $mod_reference
 * @param $module_params
 */
function module_last_youtube_playlist_videos($mod_reference, $module_params)
{
    global $smarty, $prefs;
    $tikilib = TikiLib::lib('tiki');
    $data = array();
    if (!empty($module_params['id'])) {
        $id = $module_params['id'];
        require_once 'lib/wiki-plugins/wikiplugin_youtube.php';
        if (!empty($module_params['orderby'])) {
            $orderby = $module_params['orderby'];
            $feedUrl = 'http://gdata.youtube.com/feeds/api/playlists/' . $id . '?orderby=' . $orderby;
        } else {
            $feedUrl = 'http://gdata.youtube.com/feeds/api/playlists/' . $id . '?orderby=position';
        }
        $yt = new Zend_Gdata_YouTube();
        $yt->setMajorProtocolVersion(2);
        $yt->setHttpClient($tikilib->get_http_client());
        try {
            $playlistVideoFeed = $yt->getPlaylistVideoFeed($feedUrl);
            $data[$id]['info']['title'] = $playlistVideoFeed->title->text;
            // Prepare params for video display
            $params = array();
            $params['width'] = isset($module_params['width']) ? $module_params['width'] : 425;
            $params['height'] = isset($module_params['height']) ? $module_params['height'] : 350;
            // Get information from all videos from playlist
            // Limit to $module_rows first videos if $module_rows is set
            $count_videos = 1;
            foreach ($playlistVideoFeed as $videoEntry) {
                $videoId = $videoEntry->getVideoId();
                $data[$id]['videos'][$videoId]['title'] = $videoEntry->getVideoTitle();
                $data[$id]['videos'][$videoId]['uploaded'] = $videoEntry->mediaGroup->uploaded->text;
                $data[$id]['videos'][$videoId]['description'] = $videoEntry->getVideoDescription();
                $params['movie'] = $videoId;
                $pluginstr = wikiplugin_youtube('', $params);
                $len = strlen($pluginstr);
                //need to take off the ~np~ and ~/np~ at the beginning and end of the string returned by wikiplugin_youtube
                $data[$id]['videos'][$videoId]['xhtml'] = substr($pluginstr, 4, $len - 4 - 5);
                if (isset($module_rows) && $module_rows > 0 && $count_videos >= $module_rows) {
                    break;
                }
                $count_videos++;
            }
        } catch (Exception $e) {
            $data[$id]['info']['title'] = tra('No Playlist found');
            $data[$id]['videos'][0]['title'] = $e->getMessage();
        }
    } else {
        $id = 0;
        $data[$id]['info']['title'] = tra('No Playlist found');
        $data[$id]['videos'][0]['title'] = tra('No Playlist ID was provided');
    }
    $smarty->assign('verbose', isset($module_params['verbose']) ? $module_params['verbose'] : 'y');
    $smarty->assign('link_url', isset($module_params['link_url']) ? $module_params['link_url'] : '');
    $smarty->assign('link_text', isset($module_params['link_text']) ? $module_params['link_text'] : 'More Videos');
    $smarty->assign_by_ref('data', $data[$id]);
}
开发者ID:hurcane,项目名称:tiki-azure,代码行数:60,代码来源:mod-func-last_youtube_playlist_videos.php


注:本文中的Zend_Gdata_YouTube::setHttpClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。