PHP Classes
elePHPant
Icontem

HttpRequest: Send HTTP requests to remote servers

Recommend this page to a friend!
  Info   View files Example   View files View files (23)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2015-01-10 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 448 All time: 5,886 This week: 1,099Up
Version License PHP version Categories
http-request 1.0.0BSD License5.5Networking, HTTP, PHP 5
Description Author

This package can send HTTP requests to remote servers.

It provides several classes for sending HTTP GET or POST requests with support for file uploading using form POST requests.

A separate class can be used to configure several aspects of the HTTP request to be sent like the content type or other request headers.

Picture of Gonzalo Chumillas
Name: Gonzalo Chumillas <contact>
Classes: 8 packages by
Country: Spain Spain
Innovation award
Innovation award
Nominee: 2x

Details

php.httprequest

A library for sending HTTP requests from the server side.

Installation

Download the project:

git clone https://github.com/soloproyectos/php.httprequest

and copy the classes folder in your preferred location (optionally, rename it). Finally, copy and paste the following PHP code:

require_once "< YOUR PREFERRED LOCATION >/classes/autoload.php";

Examples

Send a GET request

require_once "classes/autoload.php";
use com\soloproyectos\common\http\request\HttpRequestGet;

// sends a GET request to mysite.com
$req = new HttpRequestGet();
$req->setParam("username", "john");
$req->setParam("passwrod", "smith");
echo $req->send("http://www.mysite.com");

Send a POST request

require_once "classes/autoload.php";
use com\soloproyectos\common\http\request\HttpRequestFormFile;
use com\soloproyectos\common\http\request\HttpRequestPost;

// sends a POST request to mysite.com and attaches some files
$req = new HttpRequestPost();
$req->setParam("action", "upload-image");
$req->setFormParam("image", new HttpRequestFormFile("/path/to/image.jpg"));
echo $req->send("http://www.mysite.com");

Use a configuration object

require_once "classes/autoload.php";
use com\soloproyectos\common\http\request\HttpRequestConfig;
use com\soloproyectos\common\http\request\HttpRequestFormFile;
use com\soloproyectos\common\http\request\HttpRequestPost;

// in this case we use a configuration object
$config = new HttpRequestConfig();
$config->setOption("follow_location", true);
$config->setOption("user_agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36");
$config->setContentTypeOption("charset", "iso-8859-1");

// sends a POST request to mysite.com and attaches some files
$req = new HttpRequestPost($config);
$req->setParam("action", "upload-image");
$req->setFormParam("image", new HttpRequestFormFile("/path/to/image.jpg"));
echo $req->send("http://www.mysite.com");
  Files folder image Files  
File Role Description
Files folder imageclasses (1 file, 3 directories)
Files folder imagetest (3 files)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  classes  
File Role Description
Files folder imagearr (1 file, 1 directory)
Files folder imagehttp (1 file, 2 directories)
Files folder imagetext (1 file, 3 directories)
  Accessible without login Plain text file autoload.php Class Class source

  Files folder image Files  /  classes  /  arr  
File Role Description
Files folder imagearguments (2 files)
  Accessible without login Plain text file arr-helper.php Class Class source

  Files folder image Files  /  classes  /  arr  /  arguments  
File Role Description
  Accessible without login Plain text file arr-arguments-descriptor.php Class Class source
  Accessible without login Plain text file arr-arguments.php Class Class source

  Files folder image Files  /  classes  /  http  
File Role Description
Files folder imageexception (1 file)
Files folder imagerequest (6 files, 1 directory)
  Accessible without login Plain text file http-helper.php Class Class source

  Files folder image Files  /  classes  /  http  /  exception  
File Role Description
  Accessible without login Plain text file http-exception.php Class Class source

  Files folder image Files  /  classes  /  http  /  request  
File Role Description
Files folder imageexception (1 file)
  Accessible without login Plain text file http-request-abstract.php Class Class source
  Accessible without login Plain text file http-request-config.php Class Class source
  Accessible without login Plain text file http-request-form-data.php Class Class source
  Accessible without login Plain text file http-request-form-file.php Class Class source
  Accessible without login Plain text file http-request-get.php Class Class source
  Accessible without login Plain text file http-request-post.php Class Class source

  Files folder image Files  /  classes  /  http  /  request  /  exception  
File Role Description
  Accessible without login Plain text file http-request-exception.php Class Class source

  Files folder image Files  /  classes  /  text  
File Role Description
Files folder imageexception (1 file)
Files folder imageparser (1 file, 1 directory)
Files folder imagetokenizer (1 file)
  Accessible without login Plain text file text-helper.php Class Class source

  Files folder image Files  /  classes  /  text  /  exception  
File Role Description
  Accessible without login Plain text file text-exception.php Class Class source

  Files folder image Files  /  classes  /  text  /  parser  
File Role Description
Files folder imageexception (1 file)
  Accessible without login Plain text file text-parser.php Class Class source

  Files folder image Files  /  classes  /  text  /  parser  /  exception  
File Role Description
  Accessible without login Plain text file text-parser-exception.php Class Class source

  Files folder image Files  /  classes  /  text  /  tokenizer  
File Role Description
  Accessible without login Plain text file text-tokenizer.php Class Class source

  Files folder image Files  /  test  
File Role Description
  Accessible without login Image file image.jpg Icon Icon image
  Accessible without login Plain text file receiver.php Aux. Example script
  Accessible without login Plain text file sender.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:448
This week:0
All time:5,886
This week:1,099Up