在Facebook Messenger中有一个图标,允许用户发送他们的地理坐标.
这是否可以在Facebook Messenger平台上使用,即如果用户向我发送他们的位置,我的Chatbot是否可以访问它?如果是这样,它是如何完成的,因为我无法在webhook的响应中看到它.
我的聊天机器人工作得很好,但是我在调试欢迎消息功能时遇到了问题,因为它只在会话启动时出现(虽然我很确定它在同事手机上尝试过它并不起作用).如何重置聊天,以便将我视为与之交互的新用户?
这是我目前欢迎的PHP脚本
<?php
function webhook() {
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];
if ($verify_token === 'MYTOKEN') {
echo $challenge;
}
$input = json_decode(file_get_contents('php://input'), true);
$sender = $input['entry'][0]['messaging'][0]['sender']['id'];
$welcomejson = welcomemessage();
welcomesend($json);
function message() {
$json = '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"message":{
"text":"Welcome to My BOT!"
}
}
]
}';
return $json;
}
function send($json) {
$url = 'https://graph.facebook.com/v2.6/MYPAGEID/thread_settings?access_token=MYTOKEN';
//Initiate cURL.
$ch = curl_init($url);
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded …Run Code Online (Sandbox Code Playgroud) 我理解太阳运输的意思是太阳从日出位置移动到日落位置所需的时间,但是date_sun_info()运输似乎返回太阳正好在日出和日落位置之间的中点.
$sun_info = date_sun_info(strtotime("2006-12-12"), 31.7667, 35.2333);
foreach ($sun_info as $key => $val) {
echo "$key: " . date("H:i:s", $val) . "\n";
}
Run Code Online (Sandbox Code Playgroud)
上面的例子将输出:
日出:05
:52 :11 日落:15 :41 :21
过境:10 :46 :46
civil_twilight_begin:
05:24 :08 civil_twilight_end:16
:09 :24 nautical_twilight_begin:04
:52 :25 nautical_twilight_end:16 :41 :06
astronomical_twilight_begin :04:21:32
astronomical_twilight_end:17 :12:00
我想在我的Drupal 7网站上的mysite.com/user上添加两个新标签到用户帐户页面.我想添加添加照片节点/添加/照片和添加视频节点/添加/视频的链接,但我的模块user_menu_add的以下代码对我不起作用:
function user_menu_add_menu() {
$items['node/add/photos'] = array(
'title' => t('Add Photos'),
'page callback' => 'user_menu_add',
'page arguments' => array(1),
'access callback' => TRUE,
'access arguments' => array('access user menu add'),
'type' => MENU_LOCAL_TASK,
);
return $items;
}
Run Code Online (Sandbox Code Playgroud)
我引用的一个例子在这里工作,但仅适用于"/ user"子目录下的链接
function my_module_menu() {
$items['user/%user/funky'] = array(
'title' => t('Funky Button'),
'page callback' => 'my_module_funky',
'page arguments' => array(1),
'access callback' => TRUE,
'access arguments' => array('access funky button'),
'type' => MENU_LOCAL_TASK,
);
return $items;
}
Run Code Online (Sandbox Code Playgroud)

我的Facebook聊天机器人正在工作,但它在我的初始消息发送回来后发回了多条消息.这是我的webhook脚本(我很欣赏它是一个非常粗略的工作示例):
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];
if ($verify_token === 'MY_VERIFICATION_TOKEN') {
echo $challenge;
}
$input = json_decode(file_get_contents('php://input'), true);
$sender = $input['entry'][0]['messaging'][0]['sender']['id'];
$message = $input['entry'][0]['messaging'][0]['message']['text'];
//API Url
$url = 'https://graph.facebook.com/v2.6/me/messages?access_token=<my-token>';
//Initiate cURL.
$ch = curl_init($url);
//The JSON data.
$jsonData = '{
"recipient":{
"id":"'.$sender.'"
},
"message":{
"text":"Hey Lee!"
}
}';
//Encode the array into JSON.
$jsonDataEncoded = $jsonData;
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, …Run Code Online (Sandbox Code Playgroud) webhooks facebook-graph-api facebook-messenger facebook-chatbot
在尝试生成LetsEncript证书时,我得到以下403.
[ec2-user @ myip html] $/opt/letsencrypt/letsencrypt-auto certonly --webroot -w/var/www/html -d example.com -d www.example.com --config/etc/letsencrypt/config的.ini --agree-TOS检查新版本...请求root权限才能运行letsencrypt ...须藤/home/ec2-user/.local/share/letsencrypt/bin/letsencrypt certonly --webroot -w在/ var/www/html/myroot -d example.com -d www.example.com --config /etc/letsencrypt/config.ini --agree-tos版本:1.1-20080819版本:1.1-20080819授权程序失败.mydomain.com(HTTP-01):瓮:ACME:错误:未经授权的::客户端缺乏足够的授权::从无效响应 http://example.com/.well-known/acme-challenge/IDug1d_rT8rZNPQQfdsgfdgsdfBKRJaHMTa3kulh4HnQ [52.30.98.10 ]:403
重要说明: - 服务器报告了以下错误:
域:mydomain.com类型:未经授权的详情:从响应无效http://example.com/.well-known/acme-
挑战/ IDug1d_rT8rZNPQQkjsdgfdgdfggdfajhsTa3kulh4HnQ
403:[52.30.98.101]要修复这些错误,请确保您的域名
输入正确,并且该域的DNS A记录
包含正确的IP地址.
drupal ×2
drupal-7 ×2
facebook ×2
php ×2
.htaccess ×1
amazon-ec2 ×1
apache ×1
lets-encrypt ×1
webhooks ×1