This API is used to turn content like product reviews, comments on posts and forum threads into JSON. This API can be unleashed onto a forum / comment thread directly, or onto a product page / article page containing comments / reviews.
The Discussion API part of the Diffbot PHP client consists of three main classes: the API class, the Discussion Entity class, and the Post Entity class. We'll describe them in order. Note that the API class extends :phpSwader\\Diffbot\\Abstracts\\Api
, so be sure to read that first if you haven't already.
Basic Usage:
use Swader\Diffbot\Diffbot;
$url = 'http://some-article-to-process.com';
$diffbot = new Diffbot('my_token');
$api = $diffbot->createDiscussionApi($url);
When the Discussion API is done processing a URL, the result will be a Discussion Entity (i.e. a collection of one Discussion Entities inside an instance of :phpSwader\\Diffbot\\Entity\\EntityIterator
).
For an overview of the abstract class all Entities build on, see :phpSwader\\Diffbot\\Abstracts\\Entity
.
Every Discussion entity has children - its posts. Every Post is its own entity, and very similar to :phpSwader\\Diffbot\\Entity\\Article
, sharing many of its methods.