public/Get-TwitterStatuses_HomeTimeline.ps1

function Get-TwitterStatuses_HomeTimeline {
<#
.SYNOPSIS
    Get Tweet timelines

.DESCRIPTION
    GET statuses/home_timeline
    
    Returns a collection of the most recent Tweets and Retweets posted by the authenticating user and the users they follow. The home timeline is central to how most users interact with the Twitter service.
    
    Up to 800 Tweets are obtainable on the home timeline. It is more volatile for users that follow many users or follow users who Tweet frequently.
    
    See Working with Timelines for instructions on traversing timelines efficiently.

.PARAMETER count
    Specifies the number of records to retrieve. Must be less than or equal to 200. Defaults to 20. The value of count is best thought of as a limit to the number of tweets to return because suspended or deleted content is removed after the count has been applied.

.PARAMETER since_id
    Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.

.PARAMETER max_id
    Returns results with an ID less than (that is, older than) or equal to the specified ID.

.PARAMETER trim_user
    When set to either true , t or 1 , each Tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object.

.PARAMETER exclude_replies
    This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count Tweets — this is because the count parameter retrieves that many Tweets before filtering out retweets and replies.

.PARAMETER include_entities
    The entities node will not be included when set to false.

.NOTES
    This helper function was generated by the information provided here:
    https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline

#>

    [CmdletBinding()]
    Param(
        [string]$count,
        [string]$since_id,
        [string]$max_id,
        [string]$trim_user,
        [string]$exclude_replies,
        [string]$include_entities
    )
    Begin {

        [hashtable]$Parameters = $PSBoundParameters
                   $CmdletBindingParameters | ForEach-Object { $Parameters.Remove($_) }

        [string]$Method      = 'GET'
        [string]$Resource    = '/statuses/home_timeline'
        [string]$ResourceUrl = 'https://api.twitter.com/1.1/statuses/home_timeline.json'

    }
    Process {

        # Find & Replace any ResourceUrl parameters.
        $UrlParameters = [regex]::Matches($ResourceUrl, '(?<!\w):\w+')
        ForEach ($UrlParameter in $UrlParameters) {
            $UrlParameterValue = $Parameters["$($UrlParameter.Value.TrimStart(":"))"]
            $ResourceUrl = $ResourceUrl -Replace $UrlParameter.Value, $UrlParameterValue
        }

        Do {
    
            $OAuthSettings = Get-TwitterOAuthSettings -Resource $Resource
            Invoke-TwitterAPI -Method $Method -ResourceUrl $ResourceUrl -Parameters $Parameters -OAuthSettings $OAuthSettings | Tee-Object -Variable Results | ForEach-Object { $_ }
            
            $Parameters['max_id'] = $Results.id | Sort-Object | Select-Object -First 1
            $Parameters['count'] = ([int]($Parameters['count'])) - ([int]($Results.Count))
            If ($Parameters['count'] -le 0) { Return }

        } While ($Results)

    }
    End {

    }
}