Training day 1
สิ่งที่จะเรียนในวันนี้ ( 1 มิ.ย.2561 เวลส 09.30-12.00 น.)
1.ทำโปรแกรมรับแจ้งปัญหาอินเทอร์เน็ต แจ้งเตือนผ่านไลน์ ( แจ้งเตือนผู้สอนด้วย โดยให้สร้างเป็นกลุ่มแล้ว add ผู้สอนเป็นเพื่อน)
2.ทำ bot อวยพรวันเกิดแบบอัตโนมัติ
สิ่งที่ต้องเตรียม
1.ติดตั้งโปรแกรม wamp
2.ติดตั้งโปรแกรม notepad ++
3.ติดตั้งโปรแกรม SQLyog
4.ติดตั้งโปรแกรม Ngrok
วิธีการทำ
ตัวอย่างที่ 1 โปรแกรมรับแจังปัญหา
โปรแกรมที่ใช้
1. wamp (php,apache)
2. notepad++
3. line notify token ได้มาจาก https://notify-bot.line.me/th/
4. source code ตัวอย่าง จาก ......
5. ngrok
ตัวอย่างที่ 2 bot อวยพรวันเกิด
โปรแกรมที่ใช้
1.wamp (php,apache,mysql)
2.notepad++
3.sqlyog
4.ngrok
5.line notify token ได้มาจาก ข้อ 1
4.ตัวอย่าง ฐานข้อมูล จาก ...
5 ตัวอย่าง source code จาก ...
6. http://cron-job.org/
7.*** ถ้าหากมีปัญหาเรื่องภาษาไทยที่ส่งอ่านไม่ออก ให้เข้าเว็บไซด์นี้ http://meyerweb.com/eric/tools/dencoder/ ใส่ข้อความลงไปแล้ว copy เอามาใช้ครับ
///////////////////////////// code bot.php ///////////////////
<?php
//header('Content-type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
include('con_db.php');
//$sql = "select * from contacts";
$sql = "SELECT *,DATE_FORMAT(birth,'%d/%m/%Y') AS births,2560-YEAR(birth) AS ages ,DATE_FORMAT(birth,'%d/%m/%Y') AS birthday,CONCAT(' HAPPY BIRTHDAY ขอให้ ',NAME,' มีความสุขมาก และมีสุขภาพแข็งแรงน่ะครับ ') AS happy
FROM contacts
WHERE MONTH(STR_TO_DATE(birth,'%Y-%m-%d'))= MONTH(NOW()) AND
DAY(STR_TO_DATE(birth,'%Y-%m-%d'))= DAY(NOW()) AND id_group=4 ";
$resource = mysql_query($sql);
$count_row = mysql_num_rows($resource);
if($count_row > 0) {
while($result =mysql_fetch_array($resource)){
$name = $result['name'];
$birthday =$result['birthday'];
$age = $result['age'];
$happy = $result['happy'];
$message = "Happy birthday ".' '.$name.' '.' %E0%B8%82%E0%B8%AD%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B8%A1%E0%B8%B5%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%AA%E0%B8%B8%E0%B8%82%20%E0%B9%80%E0%B8%88%E0%B8%A3%E0%B8%B4%E0%B8%8D%E0%B9%83%E0%B8%99%E0%B8%AB%E0%B8%99%E0%B9%89%E0%B8%B2%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%87%E0%B8%B2%E0%B8%99%20%E0%B8%A1%E0%B8%B5%E0%B8%AA%E0%B8%B8%E0%B8%82%E0%B8%A0%E0%B8%B2%E0%B8%9E%E0%B8%A3%E0%B9%88%E0%B8%B2%E0%B8%87%E0%B8%81%E0%B8%B2%E0%B8%A2%E0%B9%81%E0%B8%82%E0%B9%87%E0%B8%87%E0%B9%81%E0%B8%A3%E0%B8%87%20%20%E0%B8%84%E0%B8%B4%E0%B8%94%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3%E0%B8%81%E0%B9%87%E0%B8%82%E0%B8%AD%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B8%AA%E0%B8%A1%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%9B%E0%B8%A3%E0%B8%B2%E0%B8%A3%E0%B8%96%E0%B8%99%E0%B8%B2%E0%B8%99%E0%B9%88%E0%B8%B0%E0%B8%84%E0%B8%A3%E0%B8%B1%E0%B8%9A';
echo '<iframe src="line.php?message='.$message.' "></iframe>';
}
}else{
//$results = '{"results":null}';
}
?>
/////////////////////////// code con_db.php ////////////////
<?php
$Setup_Server = 'localhost';
$Setup_User = 'root';
$Setup_Pwd = '';
$Setup_Database = 'births';
mysql_connect($Setup_Server,$Setup_User,$Setup_Pwd);
mysql_query("use $Setup_Database");
mysql_query("SET NAMES UTF8");
//mysql_query("SET NAMES TIS620");
?>
////////////////////////////////////////// line.php /////////////////////
<?php
$message = $_REQUEST['message'];
$chOne = curl_init();
curl_setopt( $chOne, CURLOPT_URL, "https://notify-api.line.me/api/notify");
// SSL USE
curl_setopt( $chOne, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt( $chOne, CURLOPT_SSL_VERIFYPEER, 0);
//POST
curl_setopt( $chOne, CURLOPT_POST, 1);
// Message
curl_setopt( $chOne, CURLOPT_POSTFIELDS, $message);
//ถ้าต้องการใส่รุป ให้ใส่ 2 parameter imageThumbnail และimageFullsize
curl_setopt( $chOne, CURLOPT_POSTFIELDS, "message=$message&imageThumbnail=https://image.makewebeasy.com/makeweb/0/n1wnGFxuP/migrate/maxresdefault.jpg&imageFullsize=https://image.makewebeasy.com/makeweb/0/n1wnGFxuP/migrate/maxresdefault.jpg");
// follow redirects
curl_setopt( $chOne, CURLOPT_FOLLOWLOCATION, 1);
//ADD header array
$headers = array( 'Content-type: application/x-www-form-urlencoded', 'Authorization: Bearer xxxxxxxxxxxxxx', );
curl_setopt($chOne, CURLOPT_HTTPHEADER, $headers);
//RETURN
curl_setopt( $chOne, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec( $chOne );
//Check error
if(curl_error($chOne)) { echo 'error:' . curl_error($chOne); }
else { $result_ = json_decode($result, true);
echo "status : ".$result_['status']; echo "message : ". $result_['message']; }
//Close connect
curl_close( $chOne );
?>
///////////////////////////////
/////////////////// database ///////////
/*
SQLyog Enterprise - MySQL GUI v8.14
MySQL - 5.0.27-community-nt : Database - birth
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`birth` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `birth`;
/*Table structure for table `contacts` */
DROP TABLE IF EXISTS `contacts`;
CREATE TABLE `contacts` (
`id` int(3) NOT NULL auto_increment,
`name` varchar(300) character set utf8 NOT NULL,
`position` varchar(300) character set utf8 NOT NULL,
`email` varchar(300) character set utf8 default NULL,
`mobile` varchar(100) character set utf8 default NULL,
`telephones` varchar(100) character set utf8 default NULL,
`id_position` int(4) default NULL,
`birth` date default NULL,
`id_group` int(2) default NULL,
`level` int(2) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=tis620 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC;
/*Data for the table `contacts` */
insert into `contacts`(`id`,`name`,`position`,`email`,`mobile`,`telephones`,`id_position`,`birth`,`id_group`,`level`) values (1,'นายสันติ สบายดี','ผู้บังคับบัญชากลุ่มงาน','aaa@gmail.com','089-999-9999','02-244-2000',1000,'2520-04-04',50,11),(2,'นายโชคดี มีชัย','นักวิชาเกิน','bbb@gmail.com','083-333-3333','02-244-3000',2000,'2521-11-11',50,11),(3,'นายภาณุวัฒน์ โชคช่วย','นักวิชาเกิน','ccc@gmail.com','084-444-4444','02-244-4000',3000,'2522-10-10',50,11);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
//////////////////
/////////////////////// line api ///////////////
<?php
define('LINE_API',"https://notify-api.line.me/api/notify");
$stickerPkg = 2; //stickerPackageId
$stickerId = 34; //stickerId
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$lineid = $_REQUEST['lineid'];
$mesg = $_REQUEST['mesg'];
$token = "TXRQ1xQsNKslFxE9NvZHE9Zs8w3zuqyxtDmHOdAE0Hz";
$message = 'ปัญหา : '.$mesg."\n".'ผู้แจ้ง : '.$name."\n".'อีเมล์: '.$email."\n".'Phone: '.$phone."\n".'Line ID: '.$lineid;
if($name<>"" || $email <> "" || $mesg <> "") {
header('Content-Type: text/html; charset=utf-8');
// $res = notify_message($message);
$res = notify_message($message,$stickerPkg,$stickerId,$token);
echo "<center>ส่งข้อความเรียบร้อยแล้ว</center>";
?>
<meta http-equiv="refresh" content="2;url=index.html">
<?php
} else {
echo "<center>Error: กรุณากรอกข้อมูลให้ครบถ้วน</center>";
}
function notify_message($message,$stickerPkg,$stickerId,$token){
$queryData = array(
'message' => $message,
'stickerPackageId'=>$stickerPkg,
'stickerId'=>$stickerId
);
$queryData = http_build_query($queryData,'','&');
$headerOptions = array(
'http'=>array(
'method'=>'POST',
'header'=> "Content-Type: application/x-www-form-urlencoded\r\n"
."Authorization: Bearer ".$token."\r\n"
."Content-Length: ".strlen($queryData)."\r\n",
'content' => $queryData
),
);
$context = stream_context_create($headerOptions);
$result = file_get_contents(LINE_API,FALSE,$context);
$res = json_decode($result);
return $res;
}
?>
///////////// line html /////////
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Line-Notify</title>
<meta name="language" content="TH" >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body{background-color:#ecf0f1!important;font-size:14px;font-family: 'THSarabunNew', tahoma, thonburi, sans-serif; }
</style>
</head>
<body>
<center>
<form name="line-notify" action="line-notify-api.php" method="post">
<table width="450" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan="2" align="center"><img src="https://png.icons8.com/color/1600/line-me.png" width="40" height="40" border="0"></td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td colspan="2" align="center"><font color="red"><b>แบบฟอร์มแจ้งปัญหาระบบเครือข่าย</b></font></td></tr>
<tr><td colspan="2" align="center"><font color="#0000ff"><b>กรุณากรอกรายละเอียดให้ครบถ้วน</b></font></td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>ชื่อ:</td><td><input class="textInput" type="text" name="name" size="25" required> *</td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>อีเมล์:</td><td><input class="textInput" type="text" name="email" size="25" required> *</td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>โทรศัพท์:</td><td><input class="textInput" type="text" name="phone" size="25" required> </td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>LINE ID:</td><td><input class="textInput" type="text" name="lineid" size="25" required></td></tr>
<tr><td colspan="2" height="10"></td></tr>
<tr><td>อาการของปัญหา:</td><td><textarea rows='5' name='mesg' cols='50' style='border: 1 solid #99FF00'>ความยาวไม่เกิน 600 ตัวอักษร</textarea>
<tr><td colspan="2" height="10"></td></tr>
<tr><td colspan=2 align="center"><input type="submit" name="submit" value=" ส่งข้อความ "></td></tr>
<tr><td colspan="2" height="10"></td></tr>
</table>
</form>
</center>
<center>
รับผมเป็นเพื่อนด้วยครับ
<div class="line-it-button" data-lang="th" data-type="friend" data-lineid="@lwp9318s" width= "500" border= "0" style="display: none;"></div>
<script src="https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js" async="async" defer="defer"></script>
</center>
</body>
</html>
//////////////
เราจะดึงข้อมูลจาก Database ส่งเข้าไลน์ยังไงครับ (PHP)
ตอบลบwbs schedule pro crack This article is so innovative and well constructed I got lot of information from this post. Keep writing related to the topics on your site.
ตอบลบThis article is so innovative and well constructed I got lot of information from this post. Keep writing related to the topics on your site. idmcracksetup.com
ตอบลบDemocracy 3
ตอบลบAcronis True Image Crack
Thanks for sharing such great information, I highly appreciate your hard-working skills which are quite beneficial for me. Sony Vegas Pro Crack
ตอบลบvirtual dj pro crack
ตอบลบsystem mechanic pro crack
kaspersky anti virus crack
removewat crack
movavi video editor crack
wondershare filmora crack
ableton live crack
Antivirus Crack
ตอบลบSuch great and nice information about software. This site gonna help me a lot in finding and using much software. Kindly make this like of content and update us. Thanks for sharing us Chimera Tool Crack . Kindly click on here and visit our website and read more
ตอบลบVery nice article. I really like this blog very much. This blog gave me a lot of information on this topic. Keep it up and keep sharing this type of blog with us.
ตอบลบcubase crack
bluebeam revu free download crack
airparrot crack
bitwig torrent
quicktime pro key
Microsoft Office Crack
Kutool For Excel Crack
Download TC Games Crack
Adobe Acrobat Pro DC Crack
ตอบลบIobit Malware Fighter Pro Crack
ตอบลบZoom Player Max Crack
Cracks
System Mechanic Pro Crack
Winrar Crack
Easeus Todo Backup Crack
It's fascinating to visit this website and read all of your friends' opinions.
ตอบลบWhile I am interested in the subject of this piece of writing, I am also excited to
acquire familiarity
among us crack
output arcade crack
wondershare mobiletrans crack
tuxera ntfs crack
Hey! This is my first visit to your blog.
ตอบลบWe are a collection of volunteers starting with one
a new project in the community in the same niche.
Your blog has provided us with useful information to work with. YOU
did a fantastic job!
windows server 2016 crack
sure cuts a lot pro crack
easeus data recovery wizard crack
privacy eraser pro crack
I was ecstatic to discover this blog.
ตอบลบI appreciate you taking the time to write this excellent read for all of us.
I relished every second of it, and I've bookmarked it for future reference.
To keep track of fresh content on your site.
wondershare filmora license key
driver booster 7 1 pro key
autodesk revit crack
I'm glad you like it as much as I did.
ตอบลบSketch, a theme for your author, is here.
a classy purchase
A lack of interest in what you have to say.
You'll be back before then, and you'll be back a lot more if you help our expansion.
driverdoc crack
vso convertxtodvd crack
avast driver updater crack
parallels desktop crack
This is really beneficial software for both you and me.
ตอบลบNo errors were detected during the audit.
It's something you can take advantage of. I hope you find it nice
anymp4 data recovery crack
wondershare video converter pro crack
wondershare pdfelement pro crack
ezvid for pc crack
I really enjoy reading your post about this Posting. This sort of clever work and coverage! Keep up the wonderful works guys, thanks for sharing
ตอบลบavira phantom vpn pro crack
apowermirror crack
dvdfab crack
itubego youtube downloader crack
fl-studio crack
I found it as funny as you.
ตอบลบYour drawing is beautiful and your prose is elegant.
I still encourage you to shake anything you want to shake.
This is what you get: uncomfortably fast, hands down
Back inside, as almost always when we take our walk.
paragon ntfs serial key
r studio download
grub2win keygen
hasleo bitlocker anywhere
lego batman the videogame pc game free download