2012-10-08 29 views
11

Ai đó có thể chỉ cho tôi đúng hướng không? Tôi biết nó phải làm với gắn một tập tin .ics, nhưng tôi chỉ có thể nhận được nó đến điểm mà một người dùng có thể tải về và sau đó nhập sự kiện vào lịch nhìn của họ? Làm cách nào tôi có thể tạo các yêu cầu họp này theo lập trình?Làm thế nào để tạo một yêu cầu họp lịch xem trong PHP?

Trả lời

5

Bạn có thể lập trình tạo ra một .ics :)

Đây là cách:

<?php 
    $date  = $_GET['date']; 
    $startTime = $_GET['startTime']; 
    $endTime = $_GET['endTime']; 
    $subject = $_GET['subject']; 
    $desc  = $_GET['desc']; 

    $ical = "BEGIN:VCALENDAR 
    VERSION:2.0 
    PRODID:-//hacksw/handcal//NONSGML v1.0//EN 
    BEGIN:VEVENT 
    UID:" . md5(uniqid(mt_rand(), true)) . "example.com 
    DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z 
    DTSTART:".$date."T".$startTime."00Z 
    DTEND:".$date."T".$endTime."00Z 
    SUMMARY:".$subject." 
    DESCRIPTION:".$desc." 
    END:VEVENT 
    END:VCALENDAR"; 

    //set correct content-type-header 
    header('Content-type: text/calendar; charset=utf-8'); 
    header('Content-Disposition: inline; filename=calendar.ics'); 
    echo $ical; 
    exit; 
?> 
18

Dưới đây là ví dụ làm việc với nhiều người tham gia:

<?php 

    $to = '[email protected],[email protected]'; 
    $subject = "Millennium Falcon"; 

    $organizer   = 'Darth Vader'; 
    $organizer_email = '[email protected]'; 

    $participant_name_1 = 'Boushh'; 
    $participant_email_1= '[email protected]'; 

    $participant_name_2 = 'Boba Fett'; 
    $participant_email_2= '[email protected]'; 

    $location   = "Stardestroyer-013"; 
    $date    = '20131026'; 
    $startTime   = '0800'; 
    $endTime   = '0900'; 
    $subject   = 'Millennium Falcon'; 
    $desc    = 'The purpose of the meeting is to discuss the capture of Millennium Falcon and its crew.'; 

    $headers = 'Content-Type:text/calendar; Content-Disposition: inline; charset=utf-8;\r\n'; 
    $headers .= "Content-Type: text/plain;charset=\"utf-8\"\r\n"; #EDIT: TYPO 

    $message = "BEGIN:VCALENDAR\r\n 
    VERSION:2.0\r\n 
    PRODID:-//Deathstar-mailer//theforce/NONSGML v1.0//EN\r\n 
    METHOD:REQUEST\r\n 
    BEGIN:VEVENT\r\n 
    UID:" . md5(uniqid(mt_rand(), true)) . "example.com\r\n 
    DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z\r\n 
    DTSTART:".$date."T".$startTime."00Z\r\n 
    DTEND:".$date."T".$endTime."00Z\r\n 
    SUMMARY:".$subject."\r\n 
    ORGANIZER;CN=".$organizer.":mailto:".$organizer_email."\r\n 
    LOCATION:".$location."\r\n 
    DESCRIPTION:".$desc."\r\n 
    ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN".$participant_name_1.";X-NUM-GUESTS=0:MAILTO:".$participant_email_1."\r\n 
    ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN".$participant_name_2.";X-NUM-GUESTS=0:MAILTO:".$participant_email_2."\r\n 
    END:VEVENT\r\n 
    END:VCALENDAR\r\n"; 

    $headers .= $message; 
    mail($to, $subject, $message, $headers);  
?> 

Ở đây tôi công bố những hình ảnh như thế nào điều này sẽ trông giống như trong Outlook và Gmail: Examples

Nếu bạn cần thêm/gỡ bỏ các tùy chọn ở đây là một tài liệu tham khảo của VCALENDAR: VCALENDAR on Wikipedia

+4

tiếng tăm để giữ cho chủ đề đi với tên người dùng và ảnh tiểu sử của bạn – ScottC

Các vấn đề liên quan