This document contains the descriptions for all interfaces used in the client.
The API interface is there as a contract for developing custom APIs, not unlike the
setTimeout($timeout = 30000)¶
- $timeout (int) – The timeout value in milliseconds. Defaults to 30000 (30 seconds)
All Diffbot API endpoints support a timeout parameter which tells them after how many milliseconds to stop expecting a response from the page being processed.
The call method should execute the remote call to the API. It must return an instance of
Swader\Diffbot\Entity\EntityIteratorcontaining the set of appropriate entities for the return value of said API. In custom APIs, these are usually
Swader\Diffbot\Entity\Wildcardentities, unless otherwise specified via a custom implementation of
This method is called automatically when
Swader\Diffbot\Interfaces\Api::callis called. It builds the URL which is to be called by the HTTPClient in
Swader\Diffbot\Diffbot::setHttpClient, and returns it. This method can be used to get the URL for the purposes of testing in third party API clients like Postman.
The EntityFactory interface is there as a contract for developing custom Entity Factories. For example, you may want to make sure that a call to an API returns specific entities rather than
Swader\Diffbot\Entity\Wildcard, or some of the predefined ones like
Swader\Diffbot\Entity\Product. A specific example would be having a custom API which processes a site with board game cards. Each card has a specific value at a specific location, and these values may correspond. Rather than manually process data in
Swader\Diffbot\Entity\Wildcardentities after a call to this custom API, you might want to define a
GameCardentity and give it fields and methods specific to the context. A custom entity factory is then used to bind the newly defined entity with the custom API.
- $response (GuzzleHttp\Message\ResponseInterface) – The response received from the API call. Must be of the GuzzleHttp v5 type. Automatic if the Guzzle client is used, but version 5 only.
Returns the entity iterator containing the appropriate entities as built by the contents of