管理获取的Instagram主题标签提要(从网格中删除照片)

时间:2014-04-07 19:15:20

标签: php fancybox feed instagram hashtag

我使用Instagram API和Fancybox Simplified来获取Instagram标签提要。说明:http://www.blueprintinteractive.com/blog/how-instagram-api-fancybox-simplified

这是要在网页上插入的PHP代码:

<?php
    // Supply a user id and an access token
    $userid = "MY_USER_ID";
    $accessToken = "MY_ACCESS_TOKEN";

    // Gets our data
    function fetchData($url){
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_TIMEOUT, 18);
         $result = curl_exec($ch);
         curl_close($ch); 
         return $result;
    }

    // Pulls and parses data.
    $result = fetchData("https://api.instagram.com/v1/tags/canon/media/recent?access_token=MY_ACCESS_TOKEN&count=18");
    $result = json_decode($result);
?>


<?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 ?>

在结果网页上,我有一张带有特定网址的不合适的insta照片。

如何从网格Feed中删除此项?

2 个答案:

答案 0 :(得分:0)

附加一些逻辑来删除您不想要的图像。我使用了一个简单的比较,只删除了一个项目,但您可以改为使用列表:

// Pulls and parses data.
$result = fetchData("https://api.instagram.com/v1/tags/canon/media/recent?access_token=MY_ACCESS_TOKEN&count=18");
$result = json_decode($result);

// Delete images according to certain specifications
foreach ($result as $id => $post) {
    if ($post->images->thumbnail->url == 'unwanted_image.jpg') {
        unset($result[$id]);
    }
}

答案 1 :(得分:0)

(代表OP发布)。

以下是我修复它的方法:

<?php foreach ($result->data as $post): ?>
    <!-- Renders images. @Options (thumbnail,low_resoulution, high_resolution) -->
<?php if ($post->images->thumbnail->url == 'http://distilleryimage11.s3.amazonaws.com/accb25dcbd9c11e3a46812e95f55900b_5.jpg') {
    continue;
    }
?>
<a class="group" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php endforeach ?>