$data = array(
"manager" => $login_acc,
"password" => $login_pas
);
$data_string = json_encode($data);
$ch = curl_init($api_signin);
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);
因為發現有很多需求需要用到curl
但如果每個都是這麼長的格式會很可觀
想問問有沒有「多個」但可能某一部分只要寫一次就行的可能?
翻阅古今