Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
¿Cómo hacer una solicitud de publicación de GuzzleHttp con cuerpo y encabezado?

No puedo entender cómo modificar este cURL en Laravel 5.8, obteniendo la respuesta {"code":"11", "message":"invalid Request found", "status":"DECLINED"} .

Aquí está mi código cURL que funciona bien (en cartero y navegador):

 $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => 'https://api.hylo.biz/Api/v1.0/Payment', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => '{ "orderId":"KJDHKSGIU768", "amount":"100", "redirect_url":"google.com" }', CURLOPT_HTTPHEADER => [ 'Authorization: Basic WUR1pYQ1hYY3U2Og2OGM6JJE5tWEDJhJDEwZReVE=', 'Content-Type: application/json', ], ]); $response = curl_exec($curl); curl_close($curl); echo $response;

Aquí está mi código laravel:

 public function process(Request $request) { // return $request['request']; $client = new \GuzzleHttp\Client(); $url = "https://api.hylo.biz/Api/v1.0/Payment"; $response = $client->request('POST', $url, [ 'headers' => [ 'Authorization' => 'Basic WUR1pYQ1hYY3U2Og2OGM6JJE5tWEDJhJDEwZReVE=', 'Content-Type' => 'application/json' ], 'form_params' => $request['request'] ]); return $response = $response->getBody(); }
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

de esta manera esta funcionando

 public function process(Request $request) { $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => 'https://api.hylo.biz/Api/v1.0/Payment', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => '{ "orderId":"KJDHKSGIU768", "amount":"100", "redirect_url":"google.com" }', CURLOPT_HTTPHEADER => [ 'Authorization: Basic WUR1pYQ1hYY3U2Og2OGM6JJE5tWEDJhJDEwZReVE=', 'Content-Type: application/json', ], ]); $response = curl_exec($curl); curl_close($curl); }

y también olvidé agregar use Illuminate\Http\Request;

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda