Skip to content

Instantly share code, notes, and snippets.

@ko31
Created October 16, 2016 21:14
Show Gist options
  • Save ko31/1ea000d60ca5296f76405e640acb7d69 to your computer and use it in GitHub Desktop.
Save ko31/1ea000d60ca5296f76405e640acb7d69 to your computer and use it in GitHub Desktop.
【WordPress】LINE Notifyにメッセージ通知する
if ( ! function_exists( 'my_send_linenotify' ) ) {
function my_send_linenotify( $message, $image_thumbnail = '', $image_fullsize = '' ) {
$url = 'https://notify-api.line.me/api/notify';
$token = '[MY_ACCESS_TOKEN]';
$response = wp_remote_post( $url, array(
'method' => 'POST',
'headers' => array(
'Authorization' => 'Bearer '.$token,
),
'body' => array(
'message' => $message,
'imageThumbnail' => $image_thumbnail,
'imageFullsize' => $image_fullsize,
),
));
if ( is_wp_error( $response ) ) {
$error_message = $response->get_error_message();
echo "Error: $error_message";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment