
Laravel tiene un wrapper HTTP para hacer peticiones que funciona desde la versión 7 del framework.
El cliente HTTP implementa (entre otras cosas), un método llamado send que posee la siguiente firma:
send(string $method, string $url, array $options = [])
Entonces, para hacer el ping a twingly solo debemos hacer lo siguiente:
$xml = '
<?xml version="1.0"?>
<methodCall>
<methodName>weblogUpdates.ping</methodName>
<params>
<param>
<value>'. config('app.name') .'</value>
</param>
<param>
<value>'. config('app.url') .'</value>
</param>
</params>
</methodCall>';
Http::withHeaders([
'Content-Type' => 'text/xml; charset=utf-8'
])->send('POST', 'https://rpc.twingly.com/', [
'body' => $xml,
]);
Si la petición fue correcta vamos a obtener una respuesta de este tipo:
<?xml version="1.0" ?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>flerror</name>
<value>
<boolean>0</boolean>
</value>
</member>
<member>
<name>message</name>
<value>
<string>Thanks for the ping.</string>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>
Los invito a leer la documentación completa de twingly.