PHP Classes

File: classes/http/request/http-request-post.php

Recommend this page to a friend!
  Classes of Gonzalo Chumillas   HttpRequest   classes/http/request/http-request-post.php   Download  
File: classes/http/request/http-request-post.php
Role: Class source
Content type: text/plain
Description: Class source
Class: HttpRequest
Send HTTP requests to remote servers
Author: By
Last change:
Date: 9 years ago
Size: 1,403 bytes
 

Contents

Class file image Download
<?php
/**
 * This file is part of Soloproyectos common library.
 *
 * @author Gonzalo Chumillas <gchumillas@email.com>
 * @license https://github.com/soloproyectos/php.common-libs/blob/master/LICENSE BSD 2-Clause License
 * @link https://github.com/soloproyectos/php.common-libs
 */
namespace com\soloproyectos\common\http\request;
use
com\soloproyectos\common\http\HttpHelper;
use
com\soloproyectos\common\text\TextHelper;

/**
 * Class HttpRequestPost.
 *
 * This class is used to send POST requests.
 *
 * @package Http
 * @author Gonzalo Chumillas <gchumillas@email.com>
 * @license https://github.com/soloproyectos/php.common-libs/blob/master/LICENSE BSD 2-Clause License
 * @link https://github.com/soloproyectos/php.common-libs
 */
class HttpRequestPost extends HttpRequestAbstract
{
   
/**
     * Sends a POST request.
     *
     * This function implements HttpRequestAbstract::send().
     *
     * @param string $url URL
     *
     * @return string
     */
   
public function send($url)
    {
       
$config = clone $this->config;
       
$config->setOption("method", "POST");
       
$config->setOption("content", $this->getFormData());
       
$config->setContentType("multipart/form-data");

       
$context = stream_context_create(array("http" => $config->getOptions()));
        return
file_get_contents(HttpHelper::addParams($url, $this->params), false, $context);
    }
}