繁体   English   中英

如何使用php rest scope在outlook日历上编写事件?

[英]How to write events on outlook calendars using php rest scope?

我可以使用oauth live connect读取我所有的hotmail日历事件和联系人。

以下是登录网址

$urls = https://login.live.com/oauth20_authorize.srf?client_id='.$auth['client_id'].'&scope=wl.signin%20wl.basic%20wl.emails%20wl.contacts_emails%20wl.contacts_calendars%20wl.calendars_update&response_type=code&redirect_uri='.$app_path;

成功登录后,我可以使用accesstoken获取所有hotmail日历事件和联系人

url = 'https://apis.live.net/v5.0/me/contacts?access_token='.$accesstoken;
url = 'https://apis.live.net/v5.0/me/events?access_token='.$accesstoken;    
response =  file_get_contents($url);
$response = json_decode($response, true);   

事件列在jquery fullcalendar中。 此外,我可以在我的jquery fullcalendar中添加事件主题,start_date,end_date和description等

在此输入图像描述

以下链接仅供我参考。

https://msdn.microsoft.com/en-IN/library/hh826523.aspx#cal_rest

$('#calendar').fullCalendar({
header: {
  left: 'prev,next today',
  center: 'title',
  right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2015-12-01',
editable: true,
events: _events,  
dayClick: function(date, allDay, jsEvent, view) {
   $('#fullCalModal').modal();
                   $.ajax({
                    url: AJAX_PATH + "/user/create_event",
                    type: 'POST',
                    data: $form.serialize(),
                    dataType: 'json',
                    success: function(result) {
                        if(result.status == "success"){
                         window.location =  result.redirect;
                        }else{                  
                            alert("error...");
                        }
                    }
                });
}
});

create_event函数

 $url = "https://apis.live.net/v5.0/me/events";
                $fuseau = date("P"); 
                $titre = "Hello"; 
                $description = "Welcome to our world";
                $data_json = '{   "Subject": "' . $titre . '",
                                  "start_time": "2015-12-22T01:30:00-11:00",
                                  "end_time": "2015-12-22T03:00:00-11:00",
                                  "location": "Coho Vineyard and Winery, 123 Main St., Redmond WA 19532",
                                  "is_all_day_event": false,
                                  "availability": "busy",
                                  "visibility": "public"                    
                                }';

                $options = array("http" => array(   "method" => "POST",
                                                    "header" => "Authorization: Bearer $accesstoken \r\n" .
                                                                "Content-type: application/json\r\n",
                                                    "content" => $data_json                                         
                                                    ));



                $context = stream_context_create($options);  

但事件未在实时服务器中创建。

请帮帮我

是的,我得到了答案。 使用cURL方法事件发布到Outlook服务器

$url = "https://apis.live.net/v5.0/me/events";                   
                $data_json = '{
                    "name": "'.$subject.'",
                    "description": "'.$description.'",
                    "start_time": "'.$new_start_date_time.':00+530",
                    "end_time": "'.$new_end_date_time.':00+530",
                    "location": "'.$location.'",
                    "is_all_day_event": true,
                    "availability": "busy",
                    "visibility": "public"
                }';
             //print_r($data_json);die;
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json); 
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            "Content-Type: application/json",
            "Authorization: Bearer " . $accesstoken, 
            "Content-length: ".strlen($data_json))
            );
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             $result = curl_exec($ch);  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM