Created
October 16, 2016 21:14
-
-
Save ko31/1ea000d60ca5296f76405e640acb7d69 to your computer and use it in GitHub Desktop.
【WordPress】LINE Notifyにメッセージ通知する
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
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