Instagram API:从具有特定主题标签的特定用户处获取帖子

Cor*_*rey 2 php api instagram

我知道这两个端点:/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);
Run Code Online (Sandbox Code Playgroud)

有人知道一个简单的方法吗?

Cor*_*rey 5

这就是我最终要做的事情,只是把它放在某个地方,只要其他人试图做同样的事情.

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);
Run Code Online (Sandbox Code Playgroud)

所以$newresult我的新对象只有来自指定用户的帖子和指定的标签.