嵌入:未定义的索引 html
如果您熟悉 embedly 嵌入文章的方式,它会为您提供一个漂亮的缩略图,单击该缩略图后,会在灯箱中打开正在嵌入的材料的预览。但是,当我单击嵌入文章的缩略图时 (示例),我在线得到 Notice: Undefined index: html in C:\wamp\www\articledisplay.php 131
第 131 行是 case 'video':
的 print $oembed['html']
,如下所示。
我猜一篇文章可能不应该作为视频嵌入,而且我显然缺少 Embedly 的一些代码 PHP github。
以前使用过 Embedly 的人可以帮我弄清楚如何解决这个问题吗?谢谢。
switch($oembed['type']) {
case 'photo':
print '<div class="embed-content"><div class="embed-wrapper">';
if (!array_key_exists('title', $oembed)) {
?><img src="<?php echo $oembed['url'] ?>"></img><?php
}
else {
?><img src="<?php echo $oembed['url'] ?>" alt="<?php echo $oembed['title'] ?>"></img><?php
}
print '</div></div>';
break;
case 'link':
case 'rich':
case 'video':
print '<div class="embed-content"><div class="embed-wrapper">';
print $oembed['html'];
print '</div></div>';
break;
case 'error':
default:
}
If you're familiar with the way embedly embeds articles, if gives you a nice thumbnail that when clicked, opens up a preview in a lightbox to the material that's being embedded. However, when I click on the thumbnail for an embedded article (example), i get Notice: Undefined index: html in C:\wamp\www\articledisplay.php on line 131
Line 131 is the print $oembed['html']
of case 'video':
, shown below.
I'm guessing an article probably isn't supposed to get embedded as a video, and I'm clearly missing some code from Embedly's PHP github.
Could anyone that's worked with Embedly before help me figure out how to resolve this? Thank you.
switch($oembed['type']) {
case 'photo':
print '<div class="embed-content"><div class="embed-wrapper">';
if (!array_key_exists('title', $oembed)) {
?><img src="<?php echo $oembed['url'] ?>"></img><?php
}
else {
?><img src="<?php echo $oembed['url'] ?>" alt="<?php echo $oembed['title'] ?>"></img><?php
}
print '</div></div>';
break;
case 'link':
case 'rich':
case 'video':
print '<div class="embed-content"><div class="embed-wrapper">';
print $oembed['html'];
print '</div></div>';
break;
case 'error':
default:
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该从 switch 语句中删除“link”大小写,oEmbed 仅具有表示“rich”和“video”的 html。 “链接”类型并不总是具有 html,这与您的示例链接相对应。
You should remove the "link" case from the switch statement, oEmbed only has html for "rich" and "video". The "link" type does not always have html, which cooresponds to your example link.