我正在使用Embed.ly PHP,您可以找到here。我一直试图用其他一些网站测试嵌入,比如来自MLB或ESPN的文章。
使用examples / oembed.php,我用$urls
数组中的前几个链接替换了几个不同的链接,看看它们将如何嵌入。我试过的链接:
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
我得到的错误:
Notice: Undefined index: provider_url
Notice: Undefined index: provider_name
我很确定embed.ly支持从这些网站嵌入,但我无法弄清楚为什么我会收到这些链接的错误。
编辑一些其他信息
当我在每次嵌入之前使用echo '<p>' . $oembed['type'] . '</p>';
时,上述两个导致“错误”被打印...其他一些打印“视频”或“照片”。
EDIT2 我的代码:http://pastebin.com/Z1P0K31E
除了我已经注意到的内容之外,我改变了一件事:require_once
路径已更改为Embedly.php
的正确路径。该文件与github上的文件完全相同。
答案 0 :(得分:1)
该问题涉及索引provider_url
和provider_name
为空的数组。
例如,$some_array['provider_url']
和$some_array['provider_name']
都有空值。我会找出这些变量的位置,然后我会向后追踪,或者如果你有一些错误堆栈/跟踪堆栈的访问权限,这也会有所帮助。
stdClass对象([error_code] =&gt; 401 [error_message] =&gt;此服务需要Embedly Pro帐户[type] =&gt;错误)You'll need a pro account whatever that is. That's the error message I got back from using their API. Case closed.