Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from greendesigned/master
Browse files Browse the repository at this point in the history
Update InstaCraft_FileService.php
  • Loading branch information
brammittendorff authored May 30, 2018
2 parents c9d5fd3 + e8cbd6a commit c1fc9a9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions services/InstaCraft_FileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private function download($url, $saveHeaders=false, $proxy=null)
* @param string $url you need to put a valid instagram url in this variable
* @return mixed this will return an array with instagram profile images
*/
public function scrape($folderId=0, $url=null)
public function scrape($folderId=0, $url=null)
{
$data = $this->download($url);

Expand All @@ -147,16 +147,17 @@ public function scrape($folderId=0, $url=null)
$json = json_decode($data);

foreach ($json->entry_data->ProfilePage as $user) {
$userMedia = $user->user->media;
$userMedia = $user->graphql->user->edge_owner_to_timeline_media;
if (!empty($userMedia)) {
$profileImages = array();
foreach ($userMedia->nodes as $key => $image) {
$instagramUrl = explode('?', $image->display_src)[0];
foreach ($userMedia->edges as $key => $edge) {
$image = $edge->node;
$instagramUrl = $image->display_url;
// if the file not exists in source
$fileFound = $this->fileExists($folderId, $image->id);
if (!$fileFound) {
$profileImages[$key]['display_src'] = $instagramUrl;
$profileImages[$key]['caption'] = $image->caption;
$profileImages[$key]['caption'] = $image->edge_media_to_caption->edges[0]->node->text;
$profileImages[$key]['id'] = $image->id;
}
}
Expand All @@ -170,7 +171,6 @@ public function scrape($folderId=0, $url=null)

return false;
}

/**
* If the file exists in the source
* @param integer $folderId the id of the source it is located in
Expand Down

0 comments on commit c1fc9a9

Please sign in to comment.