<?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);
}
}
|