PHP code example of sincco / curl

1. Go to this page and download the library: Download sincco/curl 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/ */

    

sincco / curl example snippets


use Sincco\Tools\Curl;
$url = 'https://www.amazon.com.mx';
$curl = new \Sincco\Tools\Curl;
$curl->addOption(CURLOPT_CONNECTTIMEOUT, 100);
var_dump($curl->get($url));


use Sincco\Tools\Curl;
$url = 'https://www.amazon.com.mx';
$curl = new \Sincco\Tools\Curl;
$curl->addOption(CURLOPT_CONNECTTIMEOUT, 100);
$domPage = $curl->getDom($url);
foreach ($domPage->find('div[class=s-item-container] a[class=a-link-normal s-access-detail-page  a-text-normal]') as $item) {
	var_dump($item->href);
}

$urlBase = 'http://itron.mx/api/v1/'
$curl = new \Sincco\Tools\Curl;
$curl->addOption(CURLOPT_CONNECTTIMEOUT, 100);
$curl->setMethod('POST');
$params = ['email'=>'[email protected]', 'password'=>'password'];
$token = $curl->getJson($url . 'token', $params);
$curl->setAuthorization($token->token);
$curl->setMethod('GET');
var_dump($curl->getJson($url . 'contratos?filters[contrato]=999999'));
var_dump($curl->getJson($url . 'imagenes/contrato/999999'));