Skip to content

Instantly share code, notes, and snippets.

@peerapongsam
Created August 24, 2019 14:33
Show Gist options
  • Save peerapongsam/a4aa624eab07b0e2760c412664b2fb2f to your computer and use it in GitHub Desktop.
Save peerapongsam/a4aa624eab07b0e2760c412664b2fb2f to your computer and use it in GitHub Desktop.
line-notify.php
function send_notify_curl($message, $token) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://notify-api.line.me/api/notify",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query(array("message" => $message),'','&'),
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $token",
"Content-Type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
return $response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment