使用 PHP 获取 vimeo 缩略图的最快方法是什么

发布于 2025-01-07 14:54:34 字数 485 浏览 4 评论 0原文

我使用以下 PHP 代码根据 vimeo API

    private function curl_get($url)
{
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    $return = curl_exec($curl);
    curl_close($curl);
    return $return;
}

在对页面进行分析后,我注意到curl_exec大约需要220毫秒,考虑到我只想要视频的缩略图,我发现这个时间很多。

您知道获取缩略图的更快方法吗?

I am using the following code, in PHP, to get the thumbnail (from the JSON) of a vimeo video according to the vimeo API

    private function curl_get($url)
{
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    $return = curl_exec($curl);
    curl_close($curl);
    return $return;
}

After profiling the page I noticed that it takes to curl_exec about 220 milliseconds, which I find a lot considering that I only want the thumbnail of the video.

Do you know a faster way to get the thumbnail?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

征棹 2025-01-14 14:54:34

curl_exec大约需要220毫秒

这可能是网络开销(DNS查找-连接-传输-获取传输的数据)。可能无法进一步加快速度。

确保您在本地缓存结果,这样就不必每次都重新获取它们。

it takes to curl_exec about 220 milliseconds

It's probably the network overhead (DNS lookup - connect - transfer - fetching the transferred data). It may not be possible to speed this up any further.

Make sure you are caching the results locally, so they don't have to be fetched anew every time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文