PHP code example of grithin / phpwebtools

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

    

grithin / phpwebtools example snippets


use \Grithin\Curl;

$curl = new Curl;

# can set headers either directly using 'options' or through instance attributes
$curl->options['CURLOPT_USERAGENT'] = 'harmless autobot';
$curl->user_agent = 'harmless autobot';

# can provide GET parameters as an array or as a string
$response = $curl->get('http://google.com/?s=bob');
$response = $curl->get('http://google.com/',['s'=>'bob']);


$response = $curl->post('http://google.com/',['s'=>'bob']);
$response = $curl->post('http://google.com/','s=bob');
$response = $curl->post('http://google.com/',json_encode(['bob'=>'s']));

$response = $curl->post('http://thoughtpush.com/', ['s'=>'bob'], ['file1'=>'@'.__FILE__]);


use \Grithin\Curl;

$curl = new Curl;
$response = $curl->get('http://thoughtpush.com');

\Grithin\Debug::out($response->headers);
/*
[base:index.php:14] 1: [
	'Http-Version' : '1.1'
	'Status-Code' : '200'
	'Status' : '200 OK'
	'Server' : 'nginx/1.4.6 (Ubuntu)'
	'Date' : 'Fri, 09 Oct 2015 19:36:01 GMT'
	...
*/
\Grithin\Debug::out($response->body);
/*
[base:index.php:15] 2: '<?xml version="1.0" encoding="utf-8"

$curl->options[CURLOPT_VERBOSE] = true;

list($dom, $xpath) = DomTools::loadHtml($response->body);