$data = array(
"manager" => $login_acc,
"password" => $login_pas
);
$data_string = json_encode($data);
$ch = curl_init('https://');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);
$data = json_decode($result);
因為要處理http api,可能會有數十個
但每個都那麼長似乎不太好管理
想問說能怎麼樣簡寫才對?