function getResponse($url, $aParameters)
{
// Inicializar sesion y establecer url
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// curl devuelve la respuesta en lugar de darle salida
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $aParameters);
// Obtener la respuesta y cerrar
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
Y la llamada sería:
$url="https://api.example.com/resource";
$aParameters = array();
$aParameters[] = "Accept: application/xml";
$response1 = getResponse($url,$aParameters);
No hay comentarios:
Publicar un comentario