Created
August 24, 2019 14:33
-
-
Save peerapongsam/a4aa624eab07b0e2760c412664b2fb2f to your computer and use it in GitHub Desktop.
line-notify.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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