Php 未定义索引vimeo
我正在使用一个函数获取vimeo数据,但它抛出了一个警告,提示如下: 注意:未定义索引:第117行/Users/admin/Dropbox/Sites/wordpresskeletonfog/wp content/themes/skeleton/page-watch.php中的url 我的代码块中的第117行引用了下面的代码 //从url获取视频url,或使用默认值 有什么想法吗?非常感谢Php 未定义索引vimeo,php,vimeo,Php,Vimeo,我正在使用一个函数获取vimeo数据,但它抛出了一个警告,提示如下: 注意:未定义索引:第117行/Users/admin/Dropbox/Sites/wordpresskeletonfog/wp content/themes/skeleton/page-watch.php中的url 我的代码块中的第117行引用了下面的代码 //从url获取视频url,或使用默认值 有什么想法吗?非常感谢 <?php function curl_get($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; ?>
使用
而不是
$video_url = ($_GET['url']) ? $_GET['url'] : 'http://vimeo.com/' . $id;
首先,您需要检查
url
是否存在于$\u GET
中<代码>isset函数将执行此操作。如果您获得未定义的索引“Upload Offset”,则在Vimeo.php文件中的所有位置将“Upload Offset”更改为“Upload Offset”,错误已得到修复
它也在
$video_url = ($_GET['url']) ? $_GET['url'] : 'http://vimeo.com/' . $id;