Instagram API:获取来自某个用户的帖子,该用户也有某个标签


Instagram API: Get posts from a certain user that also has a certain hashtag

我知道这两个端点:/users/{user-id}/media/recent/tags/{tag-name}/media/recent

但我试图只获取某个用户的帖子,这些帖子也有特定的标签。有简单的方法吗?

目前我正在使用Instagram PHP API库,做这样的事情:

require 'vendor/Instagram-PHP-API/instagram.class.php';
$api = new Instagram('API KEY');
// Get Hashtag Search
$result = $api->getTagMedia('somehashtag', 4); // This brings me back the last 4 posts by any user :/   
// Store in a local file for JS consumption
$json = json_encode($result);
$file = TEMPLATEPATH . '/js/instagrams.json';
$fh = fopen($file, 'w');
fwrite($fh, $json);
fclose($fh);

有人知道简单的方法吗?

这就是我最终所做的,只是把它放在某个地方,以防其他人也在尝试做同样的事情。

require 'vendor/Instagram-PHP-API/instagram.class.php';
$api = new Instagram('API KEY'); // Client ID
// Get Recent Search
$result = $api->getUserMedia('THE USER ID', 20);
$data = $result->data;
$newresult = new stdClass();
$newdata = array();

foreach($data as $index=>$instagram) {
    if (in_array('somehashtag', $instagram->tags)) {
        array_push($newdata, $instagram);
    }
}
$newresult->data = $newdata;
$json = json_encode($newresult);
$file = TEMPLATEPATH . '/js/instagrams.json';
$fh = fopen($file, 'w');
fwrite($fh, $json);
fclose($fh);

所以$newresult是我的新对象,它只包含来自指定用户的带有指定标签的帖子。