public static function searchTagsByTagName($tag)
{
$response = Request::get(Endpoints::getGeneralSearchJsonLink($tag));
if ($response->code === 404) {
throw new InstagramNotFoundException('Account with given username does not exist.');
}
if ($response->code !== 200) {
throw new InstagramException('Response code is ' . $response->code . '. Body: ' . $response->body . ' Something went wrong. Please report issue.');
}
$jsonResponse = json_decode($response->raw_body, true);
if (!isset($jsonResponse['status']) || $jsonResponse['status'] != 'ok') {
throw new InstagramException('Response code is not equal 200. Something went wrong. Please report issue.');
}
if (!isset($jsonResponse['hashtags']) || count($jsonResponse['hashtags']) == 0) {
return [];
}
$hashtags = [];
foreach ($jsonResponse['hashtags'] as $jsonHashtag) {
$hashtags[] = Tag::fromSearchPage($jsonHashtag['hashtag']);
}
return $hashtags;
}