【发布时间】:2019-03-17 06:09:45
【问题描述】:
我有 curl 到函数初始化会话 1 与从 curl 传输的元素,但在此函数无法使用从 curl 获得的键和值重新初始化新会话 1。但是,当我在 curl 调用未结束的链接链接上执行 F5 时,仍然初始化会话,请让我
public function createSession(){
$params = $request->all();
$key = uniqid();
$request->session()->put($key, $params);
return response()->json([
'success' => true,
'key' => $key,
]);
}
卷曲:
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, count($params));
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); // Time out 60s
curl_setopt($ch, CURLOPT_TIMEOUT, 60); // connect time out 60s
$result = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_error($ch)) {
return false;
}
if ($status != 200) {
curl_close($ch);
return false;
}
// close curl
curl_close($ch);
return json_decode($result);
【问题讨论】: