Embed.ly PHP:未定义的provider_url和provider_name
我正在使用 Embed.ly PHP,您可以在此处找到它。我一直在尝试在其他一些网站上测试嵌入,例如来自 MLB 或 ESPN 的文章。
我从 example/oembed.php 开始工作,用几个不同的链接替换了 $urls
数组中的前几个链接,以查看它们如何嵌入。我尝试过的链接:
http://sports.espn.go.com/ ncf/新闻/故事?id=6688739
http://mlb.mlb.com/news/article.jsp?ymd=20110621&content_id=20815268&vkey=news_mlb&c_id=mlb
我在其位置得到的错误:
Notice: Undefined index: provider_url
Notice: Undefined index: provider_name
我我相当确定 embed.ly 支持从这些网站嵌入,但我不明白为什么我会收到这些错误链接。
一些附加信息
编辑当我使用 '时的 。 $oembed['类型'] 。 'echo '
在每次嵌入之前,上述两个结果会导致打印“错误”...其他一些打印“视频”或“照片”。
EDIT2 我的代码:http://pastebin.com/Z1P0K31E
我改变了一件事除了我已经注意到的之外: require_once
路径已更改为 Embedly.php
的正确路径。该文件与 github 上找到的文件一模一样。
I'm working with Embed.ly PHP, which you can find here. I've been trying to test out embedding with a few other sites, like articles from MLB or ESPN.
Working from examples/oembed.php, I replaced the first few links in the $urls
array with a couple different links to see how they would embed. The links I tried:
http://sports.espn.go.com/ncf/news/story?id=6688739
http://mlb.mlb.com/news/article.jsp?ymd=20110621&content_id=20815268&vkey=news_mlb&c_id=mlb
The errors I get in their place:
Notice: Undefined index: provider_url
Notice: Undefined index: provider_name
I'm fairly sure embed.ly supports embedding from these sites, but I can't figure out why I'm getting errors for these links.
EDIT Some additional info
When I use echo '<p>' . $oembed['type'] . '</p>';
right before each embed, the two above result in "error" being printed... some of the other ones print "video" or "photo".
EDIT2 My code: http://pastebin.com/Z1P0K31E
I changed a one thing besides what I already noted: require_once
path was changed to correct path of Embedly.php
. That file is left exactly as it was found on github.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题涉及索引
provider_url
和provider_name
为空的数组。例如,
$some_array['provider_url']
和$some_array['provider_name']
具有空值。我会找出这些变量在哪里,然后我会向后跟踪,或者如果您可以访问错误堆栈/跟踪堆栈,这也会很有帮助。stdClass Object ( [error_code] => 401 [error_message] => 此服务需要 Embedly Pro 帐户 [type] => error )
无论是什么,您都需要一个专业帐户。这是我使用他们的 API 得到的错误消息。案件已结。
The issue concerns arrays that have indices
provider_url
andprovider_name
that are empty.So for example, there is
$some_array['provider_url']
and$some_array['provider_name']
that have empty values. I would find out where these variables are, and then I would track backwards or if you have some access to an error stack / trace stack, that would also be helpful.stdClass Object ( [error_code] => 401 [error_message] => This service requires an Embedly Pro account [type] => error )
You'll need a pro account whatever that is. That's the error message I got back from using their API. Case closed.