Friday, May 4, 2018

curl with laravel return session expired - development

curl with laravel return session expired

I use curl with laravel and I need to launch a function inside a controller.

but when I put

dd('test'); 

after the namespace it’s print.but when I try with the function a have a session expired

this is the code for the curl

// Préparation des données
  $data = [];
  $data["code__client"] = "VERTDIS13";
  $data["status"] = "90";
  $data["numero__incident"] = "INC544842";

  // On tranforme le tableau PHP en objet JSON
  $data = json_encode($data);

  // Envoi au serveur
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,"http://localhost:3000/notification/server");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, "data=" . $data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_COOKIESESSION, true);
  curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
  $server_output = curl_exec($ch);
  $error = curl_error($ch);
  if($error!=""){ dd($error);}
  curl_close($ch);


  // Ici pour tester j'affiche ce que le serveur renvoi
  return $server_output;

inside the controller I tried to print data but it doesn’t work

do you see the issue ?

thanks for help .



from Laravel Questions and Answers https://laravelquestions.com/laravel/curl-with-laravel-return-session-expired/
via Lzo Media

No comments:

Post a Comment