<commit_before>Instagram Parser
=================
Initial release of an Instagram website parser. It acts like an API, but 
crawling the web.

## Installation
```shell
composer require mineur/instagram-parser:dev-master
```

## Basic initialization
Instantiate the GuzzleHttpClient adapter with just a query ID! :)


## Parsers
The Instagram Factory class gives you the following methods to retrieve the 
different Instagram web resources:

### Tags Parser
This method will give you all the posts related to the passed tag.
Is mandatory to pass the `queryId` because this endpoint uses the Facebook's 
GraphQL.
```php
use Mineur\InstagramParser\Instagram;
use Mineur\InstagramParser\Model\InstagramPost;

$queryId = '17882293912014529';
Instagram::createTagParser($queryId)
    ->parse('sun', function(InstagramPost $post) {
        dump($post);
    });
```
- It is not necessary to cast the InstagramPost object if you don't want to.
- You also don't need to get the data via callback, you can just use 
`->parse('tag_name');` to get the returned InstagramPost object.

#### InstagramPost object
Once you run the tags parser in your console, you will get an infinite bunch of
objects similar to this one:
```php
Mineur\InstagramParser\Model\InstagramPost {#36
  -id: 1539101913268979330
  -comment: """
    ¡Disfruta del sol pero sin quemarte! #wearsunscream #cremasolar
    """
  -commentsCount: 0
  -shortCode: "BVb_QkdhaC"
  -takenAtTimestamp: "149769267"
  -dimensions: Mineur\InstagramParser\Model\MediaDimensions {#31
    -height: 1079
    -width: 1080
  }
  -likesCount: 21
  -mediaSrc: "https://scontent-mrs1-1.cdnins/672_n.jpg"
  -thumbnailSrc: "https://cdninstagr.am/84672_n.jpg"
  -ownerId: "1103553924"
  -video: false
  -commentsDisabled: false
}
```
Then you will only have to access it by is getters. Like so:
```php
//...
->parse('soccer', function($post) {
    echo $post->getComment();
    echo $post->getLikesCount();
    //...
});
```
> Be careful! I recommend you to enqueue the output result and treat it 
> separately, some of the Tags can have thousands of posts related to.

### User Parser
This will give you the user info. In this case you don't need any `queryId`.
```php
use Mineur\InstagramParser\Instagram;
use Mineur\InstagramParser\Model\User;

Instagram::createUserParser()
    ->parse('github', function(User $user) {
        echo $user->getFullName();
    });
```

#### User object
Once you run the parser you will get a USer object like this one:
```php
Mineur\InstagramParser\Model\User {#33
  -id: "182889088"
  -username: "alexcm14"
  -fullName: "<NAME>"
  -biography: "Software craftsman apprentice"
  -follows: 19
  -followedBy: 12
  -externalUrl: null
  -countryBlock: false
  -isPrivate: false
  -isVerified: true
  -profilePictureUrl: "https://insta.gram.net/t870_a.jpg"
  -profilePictureUrlHd: "https://insta.gram.net/t8x70_a.jpg"
  -connectedFacebookPage: null
  -media: array:12 [
      // user media array
  ]
```

## TODO:
- Parse tags from the comment string and add it as an array on a object 
property named `tag`.
- Parse multiple elements at once.
- Test it using phpunit.<commit_msg>Fix docs<commit_after>Instagram Parser
=================
Initial release of an Instagram website parser. It acts like an API, but 
crawling the web.

## Installation
```shell
composer require mineur/instagram-parser:dev-master
```

## Initialization
The Instagram Factory class gives you the following methods to retrieve the 
different Instagram web resources:

### Tags Parser
This method will give you all the posts related to the passed tag.
Is mandatory to pass the `queryId` because this endpoint uses the Facebook's 
GraphQL.
```php
use Mineur\InstagramParser\Instagram;
use Mineur\InstagramParser\Model\InstagramPost;

$queryId = '17882293912014529';
Instagram::createTagParser($queryId)
    ->parse('sun', function(InstagramPost $post) {
        dump($post);
    });
```
- It is not necessary to cast the InstagramPost object if you don't want to.
- You also don't need to get the data via callback, you can just use 
`->parse('tag_name');` to get the returned InstagramPost object.

#### InstagramPost object
Once you run the tags parser in your console, you will get an infinite bunch of
objects similar to this one:
```php
Mineur\InstagramParser\Model\InstagramPost {#36
  -id: 1539101913268979330
  -comment: """
    ¡Disfruta del sol pero sin quemarte! #wearsunscream #cremasolar
    """
  -commentsCount: 0
  -shortCode: "BVb_QkdhaC"
  -takenAtTimestamp: "149769267"
  -dimensions: Mineur\InstagramParser\Model\MediaDimensions {#31
    -height: 1079
    -width: 1080
  }
  -likesCount: 21
  -mediaSrc: "https://scontent-mrs1-1.cdnins/672_n.jpg"
  -thumbnailSrc: "https://cdninstagr.am/84672_n.jpg"
  -ownerId: "1103553924"
  -video: false
  -commentsDisabled: false
}
```
Then you will only have to access it by is getters. Like so:
```php
//...
->parse('soccer', function($post) {
    echo $post->getComment();
    echo $post->getLikesCount();
    //...
});
```
> Be careful! I recommend you to enqueue the output result and treat it 
> separately, some of the Tags can have thousands of posts related to.

### User Parser
This will give you the user info. In this case you don't need any `queryId`.
```php
use Mineur\InstagramParser\Instagram;
use Mineur\InstagramParser\Model\User;

Instagram::createUserParser()
    ->parse('github', function(User $user) {
        echo $user->getFullName();
    });
```

#### User object
Once you run the parser you will get a User object like this one:
```php
Mineur\InstagramParser\Model\User {#33
  -id: "182889088"
  -username: "alexcm14"
  -fullName: "<NAME>"
  -biography: "Software craftsman apprentice"
  -follows: 19
  -followedBy: 12
  -externalUrl: null
  -countryBlock: false
  -isPrivate: false
  -isVerified: true
  -profilePictureUrl: "https://insta.gram.net/t870_a.jpg"
  -profilePictureUrlHd: "https://insta.gram.net/t8x70_a.jpg"
  -connectedFacebookPage: null
  -media: array:12 [
      // user media array
  ]
```

## TODO:
- Parse tags from the comment string and add it as an array on a object 
property named `tag`.
- Tags Streaming parser.
- Parse multiple tags at once.
- Test it using phpunit.
- Geolocation parser and Geolocation streaming parser.

{'fraction_non_alphanumeric': 0.11887665549704803, 'fraction_numerical': 0.03350885591191958, 'mean_word_length': 3.97065820777161, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7330198', 'n_tokens_mistral': 2179, 'n_tokens_neox': 1985, 'n_words': 680}