이 기사는 Marc Towler와 Bruno Mota가 검토 한 동료였습니다. Sitepoint 콘텐츠를 최대한 활용 한 Sitepoint의 동료 검토 자 덕분에!
Google Twilio
이것은 클라이언트 ID와 클라이언트 비밀을 표시하는 모달을 엽니 다. 우리가 나중에 사용할 것이므로 지금 그들을 주목하십시오.
Twilio Twilio 계정을 만든 후에는 설정 페이지로 이동하여 Live API 자격 증명에 따라 계정 및 Authtoken의 값을 기록하십시오.
앱 구축
모든 종속성을 설치하려면 터미널에서 NPM 설치를 실행하십시오.
데이터베이스
앞에서 언급 했듯이이 앱에는 MySQL 데이터베이스를 사용하겠습니다. 선택한 데이터베이스 관리 도구를 사용하여 새로운 데이터베이스를 만듭니다. 그런 다음 다음 SQL 덤프 파일을 사용하여 테이블을 만듭니다 : 약속---otifier.sql. .
Google
결론
그게 다야! 이 튜토리얼에서는 Twilio와 함께 SMS 알림 앱을 만드는 방법을 배웠습니다. 구체적으로 Google Calendar API를 통해 사용자의 약속을 얻는 방법을 살펴 보았습니다. 우리는 데이터베이스에 저장하고 Twilio를 통해 사용자에게 알렸다. Github Repo 에서이 자습서에서 사용 된 코드를 찾을 수 있습니다. > 예, 여러 사용자 에게이 앱을 사용할 수 있습니다. 약속을 특정 사용자와 연결하고 알림을 올바른 전화 번호로 전송하는지 확인하려면 코드를 수정해야합니다. 여기에는 데이터베이스에서 사용자 인증을 추가하고 사용자 데이터를 관리하는 것이 포함될 수 있습니다. 이 앱을 기존 스케줄링 시스템과 통합 할 수 있습니까? 국제 번호로 알림을 보낼 수 있습니까?
구성 - 글로벌 앱 구성 저장 및 검색에 사용됩니다.
시간
{
"name": "google-calendar-twilio",
"version": "0.0.1",
"dependencies": {
"config": "^1.17.1",
"cron": "^1.1.0",
"express": "^4.13.3",
"googleapis": "^2.1.6",
"moment": "^2.10.6",
"moment-timezone": "^0.4.1",
"mysql": "felixge/node-mysql",
"twilio": "^2.6.0"
}
}
{
"app": {
"timezone": "Asia/Manila"
},
"me": {
"phone_number": ""
},
"db": {
"host": "localhost",
"user": "root",
"password": "secret",
"database": "calendar_notifier"
},
"google":{
"client_id": "THE CLIENT ID OF YOUR GOOGLE APP",
"client_secret": "THE CLIENT SECRET OF YOUR GOOGLE APP",
"redirect_uri": "http://localhost:3000/login",
"access_type": "offline",
"scopes": [
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/calendar"
]
},
"twilio": {
"sid": "YOUR TWILIO SID",
"secret": "YOUR TWILIO SECRET",
"phone_number": "+YOUR TWILIO PHONE NUMBER / SANDBOX NUMBER"
}
}
.
{
"name": "google-calendar-twilio",
"version": "0.0.1",
"dependencies": {
"config": "^1.17.1",
"cron": "^1.1.0",
"express": "^4.13.3",
"googleapis": "^2.1.6",
"moment": "^2.10.6",
"moment-timezone": "^0.4.1",
"mysql": "felixge/node-mysql",
"twilio": "^2.6.0"
}
}
{
"app": {
"timezone": "Asia/Manila"
},
"me": {
"phone_number": ""
},
"db": {
"host": "localhost",
"user": "root",
"password": "secret",
"database": "calendar_notifier"
},
"google":{
"client_id": "THE CLIENT ID OF YOUR GOOGLE APP",
"client_secret": "THE CLIENT SECRET OF YOUR GOOGLE APP",
"redirect_uri": "http://localhost:3000/login",
"access_type": "offline",
"scopes": [
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/calendar"
]
},
"twilio": {
"sid": "YOUR TWILIO SID",
"secret": "YOUR TWILIO SECRET",
"phone_number": "+YOUR TWILIO PHONE NUMBER / SANDBOX NUMBER"
}
}
{
"name": "google-calendar-twilio",
"version": "0.0.1",
"dependencies": {
"config": "^1.17.1",
"cron": "^1.1.0",
"express": "^4.13.3",
"googleapis": "^2.1.6",
"moment": "^2.10.6",
"moment-timezone": "^0.4.1",
"mysql": "felixge/node-mysql",
"twilio": "^2.6.0"
}
}
{
"app": {
"timezone": "Asia/Manila"
},
"me": {
"phone_number": ""
},
"db": {
"host": "localhost",
"user": "root",
"password": "secret",
"database": "calendar_notifier"
},
"google":{
"client_id": "THE CLIENT ID OF YOUR GOOGLE APP",
"client_secret": "THE CLIENT SECRET OF YOUR GOOGLE APP",
"redirect_uri": "http://localhost:3000/login",
"access_type": "offline",
"scopes": [
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/calendar"
]
},
"twilio": {
"sid": "YOUR TWILIO SID",
"secret": "YOUR TWILIO SECRET",
"phone_number": "+YOUR TWILIO PHONE NUMBER / SANDBOX NUMBER"
}
}
var config = require('config');
var db_config = config.get('db');
var mysql = require('mysql');
var connection = mysql.createConnection({
host: db_config.host,
user: db_config.user,
password: db_config.password,
database: db_config.database
});
exports.db = connection;
var config = require('config');
var app_timezone = config.get('app.timezone');
var moment = require('moment-timezone');
moment.tz.setDefault(app_timezone);
exports.config = {
timezone: app_timezone
};
exports.moment = moment;
앱에서 알림 메시지를 사용자 정의 할 수 있습니까? var config = require('config');
var google_config = config.get('google');
var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(google_config.client_id, google_config.client_secret, google_config.redirect_uri);
var calendar = google.calendar('v3');
exports.oauth2Client = oauth2Client;
exports.calendar = calendar;
exports.config = google_config;
다른 시간대에 대한 알림을 어떻게 예약 할 수 있습니까? 다른 시간 영역에 대한 미리 알림 스케줄링은 약간 까다로울 수 있습니다. 각 약속에 대한 시간대 정보를 저장하고 알림을 예약 할 때이를 사용해야합니다. JavaScript의 날짜 객체는 시간대 전환을 처리하거나 더 복잡한 시나리오를 위해 Moment.js와 같은 라이브러리를 사용할 수 있습니다.
여러 사용자 에게이 응용 프로그램을 사용할 수 있습니까?
데이터의 보안은 앱 구현 방법에 따라 다릅니다. Twilio는 안전한 통신 채널을 제공하지만 서버와 데이터베이스가 안전한지 확인해야합니다. 여기에는 보안 프로토콜을 사용하고, 민감한 데이터를 암호화하고, 웹 보안을위한 모범 사례를 따르는 것이 포함될 수 있습니다. Twilio와 함께 SMS 알림을 보내는 데 드는 비용은 얼마입니까?
Twilio와 함께 SMS 알림을 보내는 비용은의 수에 달려 있습니다. 당신이 보내는 메시지와 당신이 그들에게 보내는 국가. Twilio는 웹 사이트에서 자세한 가격 구조를 제공합니다. 내 앱의 성능을 어떻게 모니터링 할 수 있습니까?
다양한 도구를 사용하여 앱의 성능을 모니터링 할 수 있습니다. Twilio는 SMS 사용에 대한 분석을 제공하며 서버 모니터링 도구를 사용하여 서버 측 코드의 성능을 추적 할 수 있습니다. 또한 발생하는 문제를 진단하기 위해 로깅을 구현해야합니다.
위 내용은 Twilio를 사용하여 SMS 약속 알림 앱을 구축하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!