PHP Classes

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

Recommend this page to a friend!
  Classes of Gonzalo Chumillas   HttpRequest   classes/http/request/http-request-get.php   Download  
File: classes/http/request/http-request-get.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,351 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 HttpRequestGet.
 *
 * This class is used to send GET 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 HttpRequestGet extends HttpRequestAbstract
{
   
/**
     * Sends a GET request.
     *
     * This function implements HttpRequestAbstract::send().
     *
     * @param string $url URL
     *
     * @return string
     */
   
public function send($url)
    {
       
$config = clone $this->config;
       
$config->setOption("method", "GET");
       
$config->setContentType("application/x-www-form-urlencoded");

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