Skip to content

Commit

Permalink
adapt Instagram changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kringkaste committed Jun 2, 2022
1 parent fbbd40e commit 6632974
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Instagram Feed Changelog

## Unreleased [CRITICAL]

> {note} Instagram changed the structure on 06/01/2022.
### Changed
- Adaptation to the changes in the data structure of Instagram on 06/01/2022.

## 1.1.7 - 2021-07-19

### Changed
Expand Down
30 changes: 30 additions & 0 deletions src/services/InstagramService.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ private function getInstagramAccountData(string $account): array
return [];
}

if (InstagramFeed::getInstance()->getSettings()->useProxy) {
$obj = $this->parseProxyResponse($html);
if (false === $obj) {
return [];
}

return $this->flattenMediaArray($obj['data']['user']['edge_owner_to_timeline_media']['edges'], self::STRUCTURE_VERSION_1);
}

$obj = $this->parseInstagramResponse($html);
if (false === $obj) {
return [];
Expand Down Expand Up @@ -157,6 +166,15 @@ private function getInstagramTagData(string $tag): array
return [];
}

if (InstagramFeed::getInstance()->getSettings()->useProxy) {
$obj = $this->parseProxyResponse($html);
if (false === $obj) {
return [];
}

return $this->flattenMediaArray($obj['data']['recent']['sections'], self::STRUCTURE_VERSION_2);
}

$obj = $this->parseInstagramResponse($html);
if (false === $obj) {
return [];
Expand Down Expand Up @@ -262,6 +280,18 @@ private function fetchInstagramPage(string $path): string
return $response->getBody();
}

/**
* Function to parse the response body from the proxy.
*
* @param string $response
*
* @return mixed
*/
private function parseProxyResponse(string $response)
{
return json_decode($response, true);
}

/**
* Function to parse the response body from Instagram
*
Expand Down

0 comments on commit 6632974

Please sign in to comment.