{"id":6848,"date":"2024-12-28T10:02:36","date_gmt":"2024-12-28T01:02:36","guid":{"rendered":"https:\/\/taitan916.info\/blog\/?p=6848"},"modified":"2024-11-11T15:21:53","modified_gmt":"2024-11-11T06:21:53","slug":"post-6848","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/6848","title":{"rendered":"PHP\u304b\u3089LINE\u306eMessaging API\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u901a\u77e5\u3092\u9001\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>LINE\u304b\u3089\u300c<a href=\"https:\/\/developers.line.biz\/ja\/docs\/messaging-api\/overview\/#line-official-account-plan\" target=\"_blank\" rel=\"noopener\">2025\/3\/31\u306bLINE Notify\u306e\u30b5\u30fc\u30d3\u30b9\u304c\u7d42\u4e86\u3059\u308b<\/a>\u300d\u3068\u901a\u77e5\u304c\u5c4a\u3044\u305f\u3002\u4ee3\u66ff\u624b\u6bb5\u306fMessaging API\u306e\u5229\u7528\u306b\u306a\u308b\u3068\u306e\u3053\u3068\u3002\u53d6\u308a\u6025\u304ePHP\u304b\u3089\u7279\u5b9a\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304d\u305f\u3044\u306e\u3067\u5bfe\u5fdc\u65b9\u6cd5\u3092\u4ee5\u4e0b\u306b\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u5bfe\u5fdc\u65b9\u6cd5<\/h2>\n<h3>LINE\u516c\u5f0f\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4f5c\u6210<\/h3>\n<p>Messaging API\u306fLINE\u516c\u5f0f\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002\u305d\u306e\u305f\u3081<a href=\"https:\/\/entry.line.biz\/start\/jp\/\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8<\/a>\u3088\u308a\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3002<\/p>\n<h3>Messaging API\u306e\u6709\u52b9\u5316<\/h3>\n<p>LINE\u516c\u5f0f\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3068LINE Official Account Manager\u306b\u9077\u79fb\u3059\u308b\u306e\u3067\u300c\u5de6\u5074\u30e1\u30cb\u30e5\u30fc\u306e\u8a2d\u5b9a\u2192Messaging API\u300d\u306b\u9032\u307f\u3001API\u3092\u6709\u52b9\u5316\u3059\u308b\u3053\u3068\u3002<\/p>\n<h3>LINE Developers\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4f5c\u6210\u53ca\u3073\u30ed\u30b0\u30a4\u30f3<\/h3>\n<p><a href=\"https:\/\/developers.line.biz\/ja\/\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8<\/a>\u3088\u308aLINE Developers\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u3002<\/p>\n<h3>\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u53ca\u3073\u30c1\u30e3\u30cd\u30eb\u306e\u4f5c\u6210<\/h3>\n<p>LINE Developers\u306e\u300c\u5de6\u5074\u30e1\u30cb\u30e5\u30fc\u306e\u30b3\u30f3\u30bd\u30fc\u30eb(\u30db\u30fc\u30e0)\u300d\u306b\u9032\u307f\u3001\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306e\u4f5c\u6210\u3092\u30af\u30ea\u30c3\u30af\u3057Messaging API\u3067\u30c1\u30e3\u30cd\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<h3>\u5fc5\u8981\u60c5\u5831\u306e\u53d6\u5f97<\/h3>\n<p>\u4f5c\u6210\u3057\u305f\u30c1\u30e3\u30cd\u30eb\u306e\u30da\u30fc\u30b8\u306e\u300c\u30c1\u30e3\u30cd\u30eb\u57fa\u672c\u8a2d\u5b9a\u30bf\u30d6\u300d\u5185\u306e\u30da\u30fc\u30b8\u3067\u300c\u3042\u306a\u305f\u306e\u30e6\u30fc\u30b6\u30fcID\u300d\u304c\u3042\u308b\u306e\u3067\u30e1\u30e2\u3063\u3066\u304a\u304f\u3002<\/p>\n<p>\u307e\u305f\u300cMessaging API\u8a2d\u5b9a\u30bf\u30d6\u300d\u5185\u306e\u30da\u30fc\u30b8\u3067\u300c\u30c1\u30e3\u30cd\u30eb\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u300d\u3092\u767a\u884c\u3057\u3001\u5185\u5bb9\u3092\u30e1\u30e2\u3063\u3066\u304a\u304f\u3002<\/p>\n<h3>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h3>\n<p>\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u53ca\u3073\u30e6\u30fc\u30b6\u30fcID\u306f\u4e0a\u8a18\u3067\u30e1\u30e2\u3063\u305f\u3082\u306e\u306b\u66f8\u304d\u63db\u3048\u308b\u3053\u3068\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?php\r\n\/\/\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\r\n$access_token = '\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3';\r\n\r\n\/\/\u30e6\u30fc\u30b6\u30fcID\r\n$user_id = '\u30e6\u30fc\u30b6\u30fcID';\r\n\r\n\/\/\u30e1\u30c3\u30bb\u30fc\u30b8\u672c\u6587\r\n$message = '';\r\n\r\n$data = [\r\n    'to' =&gt; $user_id,\r\n    'messages' =&gt; [\r\n        [\r\n            'type' =&gt; 'text',\r\n            'text' =&gt; $message\r\n        ]\r\n    ]\r\n];\r\n$headers = [\r\n    'Content-Type: application\/json',\r\n    'Authorization: Bearer ' . $access_token,\r\n];\r\n$ch = curl_init('https:\/\/api.line.me\/v2\/bot\/message\/push');\r\n\r\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\r\ncurl_setopt($ch, CURLOPT_POST, true);\r\ncurl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));\r\ncurl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\r\n$result = curl_exec($ch);\r\n\r\nif( curl_errno($ch) ){\r\n    \/\/\u30a8\u30e9\u30fc\u6642\u306e\u51e6\u7406\r\n    echo 'Error:' . curl_error($ch);\r\n}else{\r\n    \/\/\u6210\u529f\u6642\u306e\u51e6\u7406\r\n    echo 'Response: ' . $result;\r\n}\r\n\r\ncurl_close($ch);\r\n?&gt;<\/pre>\n<p>&nbsp;<\/p>\n<h2>\u305d\u306e\u4ed6<\/h2>\n<h3>\u7121\u6599\u30e1\u30c3\u30bb\u30fc\u30b8\u306f\u4e0a\u9650\u3042\u308a<\/h3>\n<p><a href=\"https:\/\/www.lycbiz.com\/jp\/service\/line-official-account\/plan\/\" target=\"_blank\" rel=\"noopener\">\u516c\u5f0f\u30da\u30fc\u30b8<\/a>\u306b\u3088\u308b\u3068\u7121\u6599\u30d7\u30e9\u30f3(\u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3\u30d7\u30e9\u30f3)\u306e\u5834\u5408\u3001200\u901a \/ \u6708\u306e\u9001\u4fe1\u4e0a\u9650\u304c\u3042\u308b\u3002<\/p>\n<p>\u696d\u52d9\u30b7\u30b9\u30c6\u30e0\u3068\u304b\u3067\u4f7f\u3046\u5834\u5408\u3060\u3068\u6709\u6599\u30d7\u30e9\u30f3\u3092\u691c\u8a0e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u305d\u3046\u3002\u3082\u3057\u304f\u306fChatwork\u7b49\u306e\u5225\u30b5\u30fc\u30d3\u30b9\u3078\u306e\u5909\u66f4\u3068\u304b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/h2>\n<p><a href=\"https:\/\/developers.line.biz\/ja\/reference\/messaging-api\/\" target=\"_blank\" rel=\"noopener\">https:\/\/developers.line.biz\/ja\/reference\/messaging-api\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u53c2\u8003\u30b5\u30a4\u30c8<\/h2>\n<p><a href=\"https:\/\/it-slroom.blog\/web\/php-line-api\/\" target=\"_blank\" rel=\"noopener\">https:\/\/it-slroom.blog\/web\/php-line-api\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>LINE\u304b\u3089\u300c2025\/3\/31\u306bLINE Notify\u306e\u30b5\u30fc\u30d3\u30b9\u304c\u7d42\u4e86\u3059\u308b\u300d\u3068 ... <\/p>\n","protected":false},"author":1,"featured_media":4313,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[98],"class_list":["post-6848","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-line"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/6848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/comments?post=6848"}],"version-history":[{"count":2,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/6848\/revisions"}],"predecessor-version":[{"id":6850,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/6848\/revisions\/6850"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/4313"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=6848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=6848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=6848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}