$videofilename = $photo->{'videos'}->{'standard_resolution'}->{'url'};
        }
        $datetime = date("Y-m-d H:i:s", $photo->{'created_time'});
        $lat = !empty($photo->{'location'}->{'latitude'}) ? $photo->{'location'}->{'latitude'} : 0;
        $lng = !empty($photo->{'location'}->{'longitude'}) ? $photo->{'location'}->{'longitude'} : 0;
        $city = isset($photo->{'location'}->{'name'}) ? $photo->{'location'}->{'name'} : '';
        $tags = "#";
        foreach ($photo->{'tags'} as $tag) {
            $tags .= $tag . "#";
        }
        $vars = array();
        $vars['link'] = $link;
        $vars['author'] = $author;
        $vars['text'] = $text;
        $vars['filename'] = $filename;
        $vars['videofilename'] = $videofilename;
        $vars['lat'] = $lat;
        $vars['lng'] = $lng;
        $vars['tags'] = $tags;
        $vars['datetime'] = $datetime;
        $vars['city'] = $city;
        $result = $instagram->addPost($vars);
        if ($result == false) {
            echo "Error while importing " . $filename;
        }
    }
} else {
    echo '!';
    echo '<strong>Error ' . $photos->{'meta'}->{'code'} . '</strong><br />';
    echo $photos->{'meta'}->{'error_message'};
}