使用多个 URL 时嵌入 API 以 404 响应
Embedly API responding with 404 when using multiple URLs
像这样联系 Embedly API 时:
$.getJSON('https://api.embedly.com/1/oembed?' + $.param({
url: 'http://example.com/article-1',
key: "myapikey"
}));
我得到了嵌入数据。但是当我尝试使用多个 URLs:
$.getJSON('https://api.embedly.com/1/oembed?' + $.param({
urls: 'http://example.com/article-1,http://example.com/article-2,http://example.com/article-3',
key: "myapikey"
}));
我收到来自 API 的错误响应,说 URL 未找到:
[
{
"url": "http://example.com/article-1,http://example.com/article-2,http://example.com/article-3",
"error_code": 404,
"error_message": "HTTP 404: Not Found",
"type": "error",
"version": "1.0"
}
]
尝试:
var urls = [
'http://example.com/article-1',
'http://example.com/article-2',
'http://example.com/article-3'
].map(encodeURIComponent).join(',');
$.getJSON('https://api.embedly.com/1/oembed?key=myapikey&urls='+urls)
.then(function(results){console.log(results)})
像这样联系 Embedly API 时:
$.getJSON('https://api.embedly.com/1/oembed?' + $.param({
url: 'http://example.com/article-1',
key: "myapikey"
}));
我得到了嵌入数据。但是当我尝试使用多个 URLs:
$.getJSON('https://api.embedly.com/1/oembed?' + $.param({
urls: 'http://example.com/article-1,http://example.com/article-2,http://example.com/article-3',
key: "myapikey"
}));
我收到来自 API 的错误响应,说 URL 未找到:
[
{
"url": "http://example.com/article-1,http://example.com/article-2,http://example.com/article-3",
"error_code": 404,
"error_message": "HTTP 404: Not Found",
"type": "error",
"version": "1.0"
}
]
尝试:
var urls = [
'http://example.com/article-1',
'http://example.com/article-2',
'http://example.com/article-3'
].map(encodeURIComponent).join(',');
$.getJSON('https://api.embedly.com/1/oembed?key=myapikey&urls='+urls)
.then(function(results){console.log(results)})