  | 
              
	              
	                
  
    
	 
        รบกวนสอบถามเรื่อง Line Notify ส่งออกไปค่าเดียวครับ     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                สวัสดีครับ รบกวนสอบถามการเอาตัวแปรไปให้ Line notify หน่อยครับ  
ผมทำ Full calendar อยากดึง Title ออกแล้วใช้ Line Notify  
ตอนวนลูป แล้ว echo ก็ออกมาปกติ เช่น AA BB 
แต่ใน Message Line แสดงแค่ AA 
 
Code 
<?php
error_reporting( error_reporting() & ~E_NOTICE );
date_default_timezone_set("Asia/Bangkok");
//Date
$thai_day_arr=array("อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์");
$thai_month_arr=array(
    "0"=>"",
    "1"=>"มกราคม",
    "2"=>"กุมภาพันธ์",
    "3"=>"มีนาคม",
    "4"=>"เมษายน",
    "5"=>"พฤษภาคม",
    "6"=>"มิถุนายน", 
    "7"=>"กรกฎาคม",
    "8"=>"สิงหาคม",
    "9"=>"กันยายน",
    "10"=>"ตุลาคม",
    "11"=>"พฤศจิกายน",
    "12"=>"ธันวาคม"                 
);
function thai_date($time){
    global $thai_day_arr,$thai_month_arr;
  
    $thai_date_return.= date("j",$time);
    $thai_date_return.= " " .$thai_month_arr[date("n",$time)];
    $thai_date_return.= " " .(date("Y",$time)+543);
    return $thai_date_return;
}
$eng_date=time(); // แสดงวันที่ปัจจุบัน
$date = thai_date($eng_date);
//Connect Database
$db_server 	= "localhost"; 		//hostname 
$db_user 	= "pao_calendar"; 	//username
$db_pass 	= ""; 		        //password
$db_src 	= "calendar"; 		//database
$db = new mysqli( $db_server , $db_user , $db_pass, $db_src );
$strSQL = "SELECT * 
                   FROM events 
                   WHERE MONTH(STR_TO_DATE(start,'%Y-%m-%d'))= MONTH(NOW()) 
		   AND DAY(STR_TO_DATE(start,'%Y-%m-%d'))= DAY(NOW())";
					
$resource = $db->query($strSQL);
$count_row = mysqli_num_rows($resource);
echo $count_row;
if($count_row > 0) {
 while( $row = $resource->fetch_assoc()) 
 {
    $title = $row['title'];
     
    echo $title;
  
$str = "".$date."\r\n";
$str .= "\r\n";
$str .= "เรียน เจ้าหน้าที่ OSEC ทุกท่าน \r\n";
$str .= "1.".$title."\r\n";
define('LINE_API',"https://notify-api.line.me/api/notify");
define('LINE_TOKEN',''); //เปา
function notify_message($message){
$queryData = array('message' => $message);
$queryData = http_build_query($queryData,'','&');
$headerOptions = array(
'http'=>array(
'method'=>'POST',
'header'=> "Content-Type: application/x-www-form-urlencoded\r\n"
."Authorization: Bearer ".LINE_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;
}
$res=notify_message($str);
	
  
 }
}else{
 
 
}  
?>
 
 
  Tag : PHP, MySQL, XAMPP               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2017-08-01 16:28:06 | 
                      By :
                          2038092003078642 | 
                      View :
                          3152 | 
                      Reply :
                          1 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ผมสลับที่นิดหน่อยก็ ส่งได้อยู่น่ะครับ 
 
Code (PHP) 
<?php
error_reporting( error_reporting() & ~E_NOTICE );
date_default_timezone_set("Asia/Bangkok");
define('LINE_API',"https://notify-api.line.me/api/notify");
define('LINE_TOKEN',"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); 
//Date
$thai_day_arr=array("อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์");
$thai_month_arr=array(
    "0"=>"",
    "1"=>"มกราคม",
    "2"=>"กุมภาพันธ์",
    "3"=>"มีนาคม",
    "4"=>"เมษายน",
    "5"=>"พฤษภาคม",
    "6"=>"มิถุนายน", 
    "7"=>"กรกฎาคม",
    "8"=>"สิงหาคม",
    "9"=>"กันยายน",
    "10"=>"ตุลาคม",
    "11"=>"พฤศจิกายน",
    "12"=>"ธันวาคม"                 
);
function thai_date($time){
    global $thai_day_arr,$thai_month_arr;
  
    $thai_date_return.= date("j",$time);
    $thai_date_return.= " " .$thai_month_arr[date("n",$time)];
    $thai_date_return.= " " .(date("Y",$time)+543);
    return $thai_date_return;
}
function notify_message($message){
$queryData = array('message' => $message);
$queryData = http_build_query($queryData,'','&');
$headerOptions = array(
'http'=>array(
'method'=>'POST',
'header'=> "Content-Type: application/x-www-form-urlencoded\r\n"
."Authorization: Bearer ".LINE_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;
}
$eng_date=time(); // แสดงวันที่ปัจจุบัน
$date = thai_date($eng_date);
//Connect Database
$db_server 	= "localhost"; 		//hostname 
$db_user 	= "root"; 	//username
$db_pass 	= "abc@1234"; 		        //password
$db_src 	= "mydatabase"; 		//database
$db = new mysqli( $db_server , $db_user , $db_pass, $db_src );
$strSQL = "SELECT * 
                   FROM line_events 
                   WHERE MONTH(STR_TO_DATE(start,'%Y-%m-%d'))= MONTH(NOW()) 
		   AND DAY(STR_TO_DATE(start,'%Y-%m-%d'))= DAY(NOW())";
					
$resource = $db->query($strSQL);
$count_row = mysqli_num_rows($resource);
//echo $count_row;
$num_rows = 0;
if($count_row > 0) {
 while( $row = $resource->fetch_assoc()) 
 {
    $num_rows++; 
    $title = $row['title'];
  
    //echo $num_rows.") ".$title."<br>";
  
$str = "".$date."\r\n";
$str .= "\r\n";
$str .= "เรียน เจ้าหน้าที่ OSEC ทุกท่าน \r\n";
$str .= $num_rows.") ".$title."\r\n";
echo $str."<br>";
$res=notify_message($str);
echo "<hr>";
$str = "";
 }
}else{
//echo xxx  
}  
?>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2017-08-03 02:55:08 | 
                        By :
                            ccjpn | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |