OK, after a lot of research and guessing I think I've solved it, this is my solution in case anyone needs it
<?php
namespace Drupal\mymodule\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use GuzzleHttp\Client;
class MyModuleController extends ControllerBase {
protected $httpClient;
public function __construct(Client $http_client) {
$this->httpClient = $http_client;
}
public static function create(ContainerInterface $container) {
return new static(
$container->get('http_client')
);
}
public function content() {
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$name = $user->get('name')->value;
$myurl = 'http://(remote url)?doc='.$name;
$request = $this->httpClient->request('GET',$myurl);
if ($request->getStatusCode() == 200) {
$datos = $request->getBody()->getContents();
return ['#markup' => $datos,];
}
}
}
?>
This only shows the answer as a string, now I'll have to parse it, etc, and add some security and validation.
Opinions are welcome.