这篇文章教你如何实现:“苹果表一键发送地理信息给预设联系人”
你需要以下软硬件:
1,苹果手表,安装IFTTT应用(https://itunes.apple.com/au/app/ifttt/id660944635?mt=8)
2,开通亚马逊的云服务AWS
3,开通IFTTT.com的账号
备注:
1,如果你在墙内,可能需要翻墙
2,可以用其他云服务替代AWS
步骤:
1,登录到AWS的Lambda服务,创建新函数:
import logging
def lambda_handler(event, context):
number = '+61488888888'
message = 'default text message'if event['queryStringParameters']:
if event['queryStringParameters']['number']:
number = event['queryStringParameters']['number']
logging.info('number = ' + number)
if event['queryStringParameters']['message']:
message = event['queryStringParameters']['message']
logging.info('message = ' + message)
try:
import boto3
sns = boto3.client('sns')
sns.publish(PhoneNumber = number, Message = message)
return {"statusCode": 200, \
"headers": {"Content-Type": "application/json"}, \
"body": "{\"message\": \"sms sent\"}"}
except Exception as e:
logging.exception(e);
return {"statusCode": 200, \
"headers": {"Content-Type": "application/json"}, \
"body": "{\"message\": \"sms failed\"}"}
2,给函数添加API Gateway的触发URL。类似于这样子:https://api-xxxxx-id.execute-api.ap-southeast-2.amazonaws.com/test/sms_webhook?number=0061488888888&message=This is a postman message
3,登录到IFTTT,新建Applet,触发条件选择“Button”,触发行为选择“WebHook”,URL就照上一步填写好并加入地理位置信息。
4,在苹果表上运行IFTTT,它会自动把Applet同步过来,然后显示一个大大的按钮,点击按钮,一条短信就会被发送指定手机号。