2017 © Pedro Peláez
 

library curl

Simple class for CURL implementation and DOM crawler

image

sincco/curl

Simple class for CURL implementation and DOM crawler

  • Friday, August 26, 2016
  • by ivanmiranda
  • Repository
  • 1 Watchers
  • 0 Stars
  • 513 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

curl

Simple class for CURL implementation and DOM crawler, (*1)

Installation

To add this package as a local, per-project dependency to your project, simply add a dependency on your project's composer.json file. Here is a minimal example of a composer.json file that just defines a dependency on Debug:, (*2)

{
    "require": {
        "sincco/curl": "dev-master"
    }
}

Use

Get string for a returned content

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);
}

Consume API

$urlBase = 'http://itron.mx/api/v1/'
$curl = new \Sincco\Tools\Curl;
$curl->addOption(CURLOPT_CONNECTTIMEOUT, 100);
$curl->setMethod('POST');
$params = ['email'=>'user@email.com', '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'));

NOTICE OF LICENSE

This source file is subject to the Open Software License (OSL 3.0) that is available through the world-wide-web at this URL: http://opensource.org/licenses/osl-3.0.php, (*3)

Happy coding! - ivan miranda, (*4)

The Versions

26/08 2016

dev-master

9999999-dev

Simple class for CURL implementation and DOM crawler

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

curl sfphp sincco

26/08 2016

1.0

1.0.0.0

Simple class for CURL implementation and DOM crawler

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

curl sfphp sincco