Recommend this page to a friend! |
![]() |
Info | Example | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 328 | All time: 7,164 This week: 673![]() |
Version | License | PHP version | Categories | |||
easy-curl-request 0.2.3 | Free for non-comm... | 5.4 | XML, HTTP, PHP 5 |
Description | Author | ||||||||
This package can perform HTTP requests using the CURL extension, send files via that, and can set the parameters and options to send HTTP GET and POST requests using the CURL extension functions. |
|
<?php / * Creaated by Dombi István <dombi.istvan@webdice.hu> <dombiistvan28@gmail.com> */ require_once dirname(__FILE__) . '/vendor/autoload.php';
/ * Example GET request */ $request = new Webdice\Utilities\Curl\Request('http://example.com', array('returntransfer' => 1)); $request->get(array('something' => 'value', 'other' => 'value2')); //$request->debug();
/ * Example POST request */ $request = new Webdice\Utilities\Curl\Request(
'http://posttestserver.com/post.php?dir=webdice',
array('returntransfer' => 1)
); $request->post(array('something' => 'value', 'other' => 'value2')); //$request->debug();
/ * Exmaple POST request WITH FILE TRANSFER */ $file = realpath('test.jpg'); $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $url = substr($url,0,strpos($url,'examples.php')); $request = new Webdice\Utilities\Curl\Request(
$url . 'file_receive.php',
array(
'safe_upload' => false
)
); $request->post(array(
'file' => '@' . $file,
'post' => 'value'
));
/ * Example CUSTOM REQUEST */ $request = new Webdice\Utilities\Curl\Request('http://example.com', array(
'returntransfer' => 1,
'customrequest' => 'PUT'
)); $request->send(); // and get response of request $request->getResponse(); // or get specified header $request->getResponseHeader('Content-type'); // or get all headers $request->getResponseHeaders();
This Repository contains useful classes to make some of your work much easier. Currently cURL Request and Xml Parser/Writer classes, with example codes.
#!php
$request = new Webdice\Utilities\Curl\Request('http://example.com' , array('returntransfer' => 1));
$request->get(array('something' => 'value', 'other' => 'value2'));
#!php
$request = new Webdice\Utilities\Curl\Request('http://posttestserver.com/post.php?dir=webdice' , array('returntransfer' => 1));
$request->post(array('something' => 'value', 'other' => 'value2'));
#!php
$file = realpath('test.jpg');
$request = new Webdice\Utilities\Curl\Request('http://things.local/curl_file_receive.php' , array('safe_upload' => false));
$request->post(array('file' => '@' . $file,'post' => 'value'));
#!php
$request = new Webdice\Utilities\Curl\Request('http://example.com' , array('returntransfer' => 1,'customrequest' => 'PUT'));
$request->send();
#!php
$parser = new \Webdice\Utilities\Xml\Parser('test.xml');
$arr = $parser->parse();
var_dump($arr);
Example: Parse xml content directly
#!php
$parser = new \Webdice\Utilities\Xml\Parser();
$arr = $parser->parseString('<root_element><items><item attributex="1">dsa</item></items></root_element>');
var_dump($arr);
Example: Change the return data keys !before parse method
#!php
$parser = new \Webdice\Utilities\Xml\Parser('test.xml');
$parser->changeNodeConfig('element_name', 'children_elements', 'attributes');
$arr = $parser->parse();
var_dump($arr);
Example: Change parsed response format to JSON
#!php
parser = new \Webdice\Utilities\Xml\Parser();
$parser->changeNodeConfig('element_name', 'children_elements', 'attributes');
$arr = $parser->parse('test.xml', \Webdice\Utilities\Xml\Parser::TYPE_JSON);
Example: Write xml file from array (recursively)
#!php
$parser = new \Webdice\Utilities\Xml\Parser();
$content = $parser->toXml(array(
array(
'node' => 'valami',
'value' => '',
'children' => array(
array(
'node' => 'valami1',
'value' => 'dsa',
'children' => array(
array(
'node' => 'valami2',
'value' => 'dsa1',
'children' => array(
array(
'node' => 'valami3',
'value' => 'dsa2',
'attributes' => array(
'dd3' => 7,
'dd4' => 8
)
), array(
'node' => 'valami4',
'value' => 'dsa3',
'attributes' => array(
'dd3' => 9,
'dd4' => 10
)
), array(
'node' => 'valami5',
'value' => 'dsa4',
'attributes' => array(
'dd3' => 11,
'dd4' => 12
)
),
),
'attributes' => array(
'dd3' => 5,
'dd4' => 6
)
)
),
'attributes' => array(
'dd3' => 3,
'dd4' => 4
)
)
),
'attributes' => array(
'dd1' => 1,
'dd2' => 2
)
)
), 'temp.xml');
### Who do I talk to? ###
* Repo owner or admin
* Write an email to <dombi.istvan@webdice.hu>
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Doc. | Documentation | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Example | Example script |
![]() |
/ | Curl |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
![]() | easy-curl-request-2019-10-29.zip 151KB |
![]() | easy-curl-request-2019-10-29.tar.gz 149KB |
![]() | Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
84% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.