我正在尝试显示来自Instagram的视频,但它不适用于我。我正在提供以下代码:
<?php foreach ($result->data as $post): ?>
<!-- Renders images. @Options (thumbnail,low_resoulution, high_resolution) -->
<a class="group" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php endforeach ?>
以上代码表现良好的图像,任何想法如何显示视频。如果可能比建议我的分页?
答案 0 :(得分:1)
根据doc of the API,您可以检查媒体是图片还是视频。
然后在创建HTML之前检查一下,有些事情应该可行:
<?php foreach ($result->data as $post) {
if ($post->type == "image") { ?>
<!-- Renders images. @Options (thumbnail,low_resoulution, high_resolution) -->
<a class="group" rel="group1" href="<?php $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php }
else { ?>
<video width="640" height="480" controls="controls">
<source src="<?= $post->videos->standard_resolution->url ?>" type="video/mp4">
</video>
<?}
} ?>