PHP code example of phleech / phcomments

1. Go to this page and download the library: Download phleech/phcomments library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phleech / phcomments example snippets


use PHComments\Parser;

$parser = new Parser();
$comments = $parser->randomVideo()->getComments();

// $comments = [
//    {"body":"Identity theft is not a joke, Jim!","timestamp":"9 years ago","author":"TightyDwighty","votes":"4"},
//    {"body":"Name?","timestamp":"8 months ago","author":"RandyStarbucks","votes":"0"}
// ];

$parser->setPageUrl(url: 'view_video.php?viewkey=123456789');

// results in the following page being scraped:
// https://www.pornhub.com/view_video.php?viewkey=123456789.

use PHComments\Parser;

$parser = new Parser(
    maxCommentBodyLength: 250
    maxCommentAuthorLength: 100
);

// results in any comments with a body greater than 250 chars
// or an author greater than 100 chars being removed.