paramako / pornhub-api-client
Pornhub api PHP client
v1.0
2021-10-14 09:51 UTC
Requires
- php: >=7.4
- ext-json: *
- guzzlehttp/guzzle: ^7.0
This package is auto-updated.
Last update: 2025-04-29 01:04:02 UTC
README
Pornhub api http client, written in PHP
Requirements
- PHP 7.4+
- ext-json
Setup
Composer:
composer require paramako/pornhub-api-client
Quickstart
Example Using Factory
All following examples assume this step.
$client = Paramako\Pornhub\Factory::create();
Disable Guzzle exceptions
By using method disableHttpErrorExceptions
, you will not receive any exceptions at all, but pure responses.
$client->disableHttpErrorExceptions();
Get \Psr\Http\Message\ResponseInterface object instead of Paramako\Http\Response
By using method disableResponseWrapper
, you will receive ResponseInterface object, instead of it`s wrapper.
$client->disableResponseWrapper();
Usage examples
Client has 4 resources: Vides, Stars, Categories and Tags. Getting a resource from client
$videos = $client->videos(); $stars = $client->stars(); $tags = $client->tags(); $categories = $client->categories();
Search for videos
$client->videos()->get();
With search params
$category = 'webcam'; $page = 3; $search = 'John Doe'; $client->videos()->get($category, $page, $search);
Get video by video_id
$videoId = 'some_id_here'; $client->videos()->getById($videoId);
Get stars list
$client->stars()->get();
Access the response data
If response wrapping is enabled (it`s enabled by default), data can be accessed in several ways
- As an array
$response = $client->categories()->get(); $categories = $response['categories']; foreach ($categories as $category) { // do some logic here }
- Or as an object
$response = $client->categories()->get(); $categories = $response->categories;
- Or \Psr\Http\Message\ResponseInterface object
$response = $client->categories()->get(); $categories = $response->getResponse(); // returns ResponseInterface
Example Without Factory
<?php require 'vendor/autoload.php'; $client = new \Paramako\Pornhub\Http\Client(); $stars = new \Paramako\Pornhub\Resources\Stars($client); $response = $stars->get();