PHP Classes
elePHPant
Icontem

Webdice Utilities: Send requests with Curl and parse and write XML

Recommend this page to a friend!
  Info   View files Example   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-10-29 (5 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 302 This week: 1All time: 7,236 This week: 340Up
Version License PHP version Categories
easy-curl-request 0.2.3Free for non-comm...5.4XML, 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.

The names of the options are the same as the ones defined in the PHP documentation of the CURL extension.

It also contains a XML parser class which can read an XML file or string and return the document as an array or JSON string. It is also can convert an array and save to a XML file or just return an XML string.

  Performance   Level  
Name: István Dombi <contact>
Classes: 1 package by
Country: Hungary Hungary

 

Details

README

This Repository contains useful classes to make some of your work much easier. Currently cURL Request and Xml Parser/Writer classes, with example codes.

  • CURL Request
  • XML file/string Parser/Writer

What is this repository for?

  • This repository for to have an easy group of code to the usually not easy progresses
  • 0.2.0

How do I get set up?

  • Init, install if you don't have it already or update composer
  • copy curl_examples.php, curl_file_receive.php, xml_parser_example.php, test.jpg and test.xml files to your web root, and run
  • Open the example file you want to see (curl,xml)
  • use and enjoy

CURL Examples

  • Example GET Request
#!php
$request = new Webdice\Utilities\Curl\Request('http://example.com' , array('returntransfer' => 1));
$request->get(array('something' => 'value', 'other' => 'value2'));

  • Example POST request
#!php
$request = new Webdice\Utilities\Curl\Request('http://posttestserver.com/post.php?dir=webdice' , array('returntransfer' => 1));
$request->post(array('something' => 'value', 'other' => 'value2'));
  • Example POST request with file upload
#!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'));
  • Example Custom request
#!php
$request = new Webdice\Utilities\Curl\Request('http://example.com' , array('returntransfer' => 1,'customrequest' => 'PUT'));
$request->send();

XML Parser examples

  • Example: Pass xml file to parse
#!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>
  Files folder image Files  
File Role Description
Files folder imageCurl (2 files)
Files folder imageXml (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file curl_examples.php Example Example script
Accessible without login Plain text file curl_file_receive.php Example Example script
Accessible without login Plain text file examples.php Example Example script
Accessible without login Plain text file file_receive.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Image file test.jpg Data Auxiliary data
Accessible without login Plain text file test.xml Data Auxiliary data
Accessible without login Plain text file xml_parser_example.php Example Example script

  Files folder image Files  /  Curl  
File Role Description
  Plain text file Helper.php Class Class source
  Plain text file Request.php Class Class source

  Files folder image Files  /  Xml  
File Role Description
  Plain text file Helper.php Class Class source
  Plain text file Parser.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 84%
Total:302
This week:1
All time:7,236
This week:340Up