rem42/scraper-tinypng

TinyPNG uploader via scraper

v1.0 2018-08-28 10:43 UTC

This package is auto-updated.

Last update: 2022-12-07 16:13:18 UTC


README

This scraper TinyPNG use Scraper.

Installation

$ composer require rem42/scraper-tinypng "^1.0"

Configuration

Nothing Needed

Usage

<?php

    use Scraper\Scraper\Client;
    use Scraper\ScraperTinyPNG\Request\TinyPNGUploaderRequest;
    
    $request = new TinyPNGUploaderRequest();
    $request
    	->setFileContent(file_get_contents('path to your file'))
    	->setUserAgent('Need a browser user agent to work !')
    ;
    
    $client = new Client();
    $result = $client->api($request);

In the result var there is the Upload entity wich contains all the result from tinypng json response serialized in this entity.

You can also use a web upload and you only need tu set an url :

<?php

    use Scraper\Scraper\Client;
    use Scraper\ScraperTinyPNG\Request\TinyPNGWebUploaderRequest;
    
    $request = new TinyPNGWebUploaderRequest();
    $request
    	->setUrl('url to your file')
    	->setUserAgent('Need a browser user agent to work !')
    ;
    
    $client = new Client();
    $result = $client->api($request);