LINE Beacon을 사용해 보았습니다.
를 qiita로 옮겼습니다.
작년 LINEBOT 공부회에 갔을 때,
받고 사용하지 않았기 때문에 사용하고 싶습니다.
LINE Beacon이란?

이것이 LINE Beacon입니다.

내용은 이런 느낌
전원을 켜면 녹색 램프가 빛났습니다. 
이 Beacon은
Beacon과 연결된 Bot과 친구가 된 계정
Beacon 사용 범위에 들어갈 때 Webhock 이벤트가 트리거됩니다.
지금부터 사용법을 설명합니다.
전제
먼저 전제로 LINE Bot을 만드십시오.
위의 URL에 공식 설명이 실려 있습니다.
곧 기사로하겠습니다.
Bot과 Beacon의 연결
이 페이지로 가십시오.
그러면 이 화면이 나옵니다.

Beacon을 만들 수있는 것 같습니다.
관심이 있는 분은 이 페이지를
이번에는 협력이므로 "비콘과 bot의 협력"을 선택

그러면 자신이 만드는 Bot이 나옵니다.
하나를 선택하면

이 화면이 나오므로
Beacon에 기재된 ID와 패스코드를 입력합니다.
이것으로 협력이 완료되었습니다.
스마트폰 측에서 설정
스마트폰측에서의 설정도 필요합니다.
설정 -> 개인 정보 보호 관리 선택

맨 아래의 LINE Beacon 이용에 체크를 한다

LINE Beacon을 사용할 때는 Bluetooth를 켜야 합니다.
샘플 만들기
설정은 일단 끝났으므로 샘플을 만듭니다.
참조는 여기에서
이것을 참고로 만들어 갑니다.

비콘 부분의 발췌입니다.
이벤트 유형으로 배너가 있지만,
이거야.

녹색 부분입니다.
이 기능은 엔터프라이즈 사용자에게만 공개된 것 같습니다.
사용하는 것은 "enter"만 같네요.
만든 것은 이것입니다.
<?php
$accessToken = ACCESS_TOKEN;
$json_string = file_get_contents('php://input');
$jsonObj = json_decode($json_string);
$replyToken = $jsonObj->{"events"}[0]->{"replyToken"}; //ReplyToken取得
$userId = $jsonObj->{"events"}[0]->{"source"}->{"userId"}; //userId取得
$eventType = $jsonObj->{"events"}[0]->{"type"}; //typeの取得
if($eventType == "beacon"){
ResponseLineText( $accessToken, $replyToken, "僕との距離が近づいてきました!!" );
}
function ResponseLineText($accessToken,$replyToken,$text){
$response_format_text = [
"type" => "text",
"text" => $text
];
$post_data = [
"replyToken" => $replyToken,
"messages" => [$response_format_text]
];
$ch = curl_init("https://api.line.me/v2/bot/message/reply");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:
application/json; charser=UTF-8','Authorization: Bearer ' . $accessToken));
$result = curl_exec($ch);
curl_close($ch);
}
?>
Beacon이 감지되면 메시지를 보냅니다.

하지만 조코 쵸코 통신이 끊긴 것 같습니다.

연속 해왔다.
무서운
요약
이런 느낌으로 할 수 있었습니다.
할 수 있는 폭은 넓을 것 같습니다.
Beacon은 만들 수 있는 것 같기 때문에 그쪽도 언젠가 도전해 보고 싶다.
이상입니다.
Reference
이 문제에 관하여(LINE Beacon을 사용해 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/kawa18/items/182ef0a3b713efd330d1
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
먼저 전제로 LINE Bot을 만드십시오.
위의 URL에 공식 설명이 실려 있습니다.
곧 기사로하겠습니다.
Bot과 Beacon의 연결
이 페이지로 가십시오.
그러면 이 화면이 나옵니다.

Beacon을 만들 수있는 것 같습니다.
관심이 있는 분은 이 페이지를
이번에는 협력이므로 "비콘과 bot의 협력"을 선택

그러면 자신이 만드는 Bot이 나옵니다.
하나를 선택하면

이 화면이 나오므로
Beacon에 기재된 ID와 패스코드를 입력합니다.
이것으로 협력이 완료되었습니다.
스마트폰 측에서 설정
스마트폰측에서의 설정도 필요합니다.
설정 -> 개인 정보 보호 관리 선택

맨 아래의 LINE Beacon 이용에 체크를 한다

LINE Beacon을 사용할 때는 Bluetooth를 켜야 합니다.
샘플 만들기
설정은 일단 끝났으므로 샘플을 만듭니다.
참조는 여기에서
이것을 참고로 만들어 갑니다.

비콘 부분의 발췌입니다.
이벤트 유형으로 배너가 있지만,
이거야.

녹색 부분입니다.
이 기능은 엔터프라이즈 사용자에게만 공개된 것 같습니다.
사용하는 것은 "enter"만 같네요.
만든 것은 이것입니다.
<?php
$accessToken = ACCESS_TOKEN;
$json_string = file_get_contents('php://input');
$jsonObj = json_decode($json_string);
$replyToken = $jsonObj->{"events"}[0]->{"replyToken"}; //ReplyToken取得
$userId = $jsonObj->{"events"}[0]->{"source"}->{"userId"}; //userId取得
$eventType = $jsonObj->{"events"}[0]->{"type"}; //typeの取得
if($eventType == "beacon"){
ResponseLineText( $accessToken, $replyToken, "僕との距離が近づいてきました!!" );
}
function ResponseLineText($accessToken,$replyToken,$text){
$response_format_text = [
"type" => "text",
"text" => $text
];
$post_data = [
"replyToken" => $replyToken,
"messages" => [$response_format_text]
];
$ch = curl_init("https://api.line.me/v2/bot/message/reply");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:
application/json; charser=UTF-8','Authorization: Bearer ' . $accessToken));
$result = curl_exec($ch);
curl_close($ch);
}
?>
Beacon이 감지되면 메시지를 보냅니다.

하지만 조코 쵸코 통신이 끊긴 것 같습니다.

연속 해왔다.
무서운
요약
이런 느낌으로 할 수 있었습니다.
할 수 있는 폭은 넓을 것 같습니다.
Beacon은 만들 수 있는 것 같기 때문에 그쪽도 언젠가 도전해 보고 싶다.
이상입니다.
Reference
이 문제에 관하여(LINE Beacon을 사용해 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/kawa18/items/182ef0a3b713efd330d1
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
스마트폰측에서의 설정도 필요합니다.
설정 -> 개인 정보 보호 관리 선택

맨 아래의 LINE Beacon 이용에 체크를 한다

LINE Beacon을 사용할 때는 Bluetooth를 켜야 합니다.
샘플 만들기
설정은 일단 끝났으므로 샘플을 만듭니다.
참조는 여기에서
이것을 참고로 만들어 갑니다.

비콘 부분의 발췌입니다.
이벤트 유형으로 배너가 있지만,
이거야.

녹색 부분입니다.
이 기능은 엔터프라이즈 사용자에게만 공개된 것 같습니다.
사용하는 것은 "enter"만 같네요.
만든 것은 이것입니다.
<?php
$accessToken = ACCESS_TOKEN;
$json_string = file_get_contents('php://input');
$jsonObj = json_decode($json_string);
$replyToken = $jsonObj->{"events"}[0]->{"replyToken"}; //ReplyToken取得
$userId = $jsonObj->{"events"}[0]->{"source"}->{"userId"}; //userId取得
$eventType = $jsonObj->{"events"}[0]->{"type"}; //typeの取得
if($eventType == "beacon"){
ResponseLineText( $accessToken, $replyToken, "僕との距離が近づいてきました!!" );
}
function ResponseLineText($accessToken,$replyToken,$text){
$response_format_text = [
"type" => "text",
"text" => $text
];
$post_data = [
"replyToken" => $replyToken,
"messages" => [$response_format_text]
];
$ch = curl_init("https://api.line.me/v2/bot/message/reply");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:
application/json; charser=UTF-8','Authorization: Bearer ' . $accessToken));
$result = curl_exec($ch);
curl_close($ch);
}
?>
Beacon이 감지되면 메시지를 보냅니다.

하지만 조코 쵸코 통신이 끊긴 것 같습니다.

연속 해왔다.
무서운
요약
이런 느낌으로 할 수 있었습니다.
할 수 있는 폭은 넓을 것 같습니다.
Beacon은 만들 수 있는 것 같기 때문에 그쪽도 언젠가 도전해 보고 싶다.
이상입니다.
Reference
이 문제에 관하여(LINE Beacon을 사용해 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/kawa18/items/182ef0a3b713efd330d1
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
<?php
$accessToken = ACCESS_TOKEN;
$json_string = file_get_contents('php://input');
$jsonObj = json_decode($json_string);
$replyToken = $jsonObj->{"events"}[0]->{"replyToken"}; //ReplyToken取得
$userId = $jsonObj->{"events"}[0]->{"source"}->{"userId"}; //userId取得
$eventType = $jsonObj->{"events"}[0]->{"type"}; //typeの取得
if($eventType == "beacon"){
ResponseLineText( $accessToken, $replyToken, "僕との距離が近づいてきました!!" );
}
function ResponseLineText($accessToken,$replyToken,$text){
$response_format_text = [
"type" => "text",
"text" => $text
];
$post_data = [
"replyToken" => $replyToken,
"messages" => [$response_format_text]
];
$ch = curl_init("https://api.line.me/v2/bot/message/reply");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:
application/json; charser=UTF-8','Authorization: Bearer ' . $accessToken));
$result = curl_exec($ch);
curl_close($ch);
}
?>
Reference
이 문제에 관하여(LINE Beacon을 사용해 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kawa18/items/182ef0a3b713efd330d1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)