Неопределенный индекс vimeo - PullRequest
0 голосов
/ 29 января 2012

Я использую функцию для получения данных vimeo, но выдает следующее уведомление:

Примечание: неопределенный индекс: URL-адрес в /Users/admin/Dropbox/Sites/wordpressSkeletonFog/wp-content/themes/skeleton/page-watch.php в строке 117

Строка 117 в моем блоке кода относится к коду ниже // Получить URL видео из URL или использовать значение по умолчанию

Есть идеи? Большое спасибо

 <?php
        function curl_get($url) { 
            // is cURL installed? If not die
            if (!function_exists('curl_init')) die('cURL is not installed!');

            // Create new cURL resource handle
            $curl = curl_init($url);

            //Return or print out the data (1 = return, 0 = print)
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);


        //Set Timeout in Seconds
            curl_setopt($curl, CURLOPT_TIMEOUT, 30);


        //Download the URL, and return the output
            $output = curl_exec($curl);

            // Close the cURL resources     
            curl_close($curl);
            return

        $output;
            }
        // Hard-coded endpoint
        $oembed_endpoint = 'http://vimeo.com/api/oembed';
        // The Vimeo video to be embedded
        $id = get_post_meta($post->ID, '_format_video_embed' , true);
        // Get the video url from the url, or use default
        $video_url = ($_GET['url']) ? $_GET['url'] : 'http://vimeo.com/' . $id;
        // Create the url
        $xml_url = $oembed_endpoint . '.xml?url=' . rawurlencode($video_url) . '&width=640';
        // Load in the oEmbed XML
        $oembed = simplexml_load_string(curl_get($xml_url));
        ?>
        <?php
        // oEmbed Result
        echo html_entity_decode($oembed->html); 
        ?>
        <?php
        echo $oembed->title 
        ?>
        <?php
        echo $oembed->author_name 
        ?>
        <?php
        echo $oembed->description 
        ?>
        <?php  endwhile; ?>

1 Ответ

0 голосов
/ 29 января 2012

ИСПОЛЬЗОВАНИЕ

$video_url = isset($_GET['url']) ? $_GET['url'] : 'http://vimeo.com/' . $id;

Вместо

$video_url = ($_GET['url']) ? $_GET['url'] : 'http://vimeo.com/' . $id;

Сначала вам нужно проверить, существует ли url в $_GET. isset функция будет это.

...