Php API Office 365以用户日历格式创建事件错误
我正在使用Office 365在用户日历中发布事件。我的帖子格式有问题 下面是我使用Codeigniter和Rest库的代码:Php API Office 365以用户日历格式创建事件错误,php,api,rest,office365,outlook-restapi,Php,Api,Rest,Office365,Outlook Restapi,我正在使用Office 365在用户日历中发布事件。我的帖子格式有问题 下面是我使用Codeigniter和Rest库的代码: $config = array ( 'server' => 'https://outlook.office365.com/api/v1.0/me', 'http_user' => 'mail@domain.com', 'http_pass' =&g
$config = array (
'server' => 'https://outlook.office365.com/api/v1.0/me',
'http_user' => 'mail@domain.com',
'http_pass' => 'mypassword',
'http_auth' => 'basic',
);
$this->load->library('rest', $config);
$event = array(
'Subject' => 'Try to post :(',
'Body' => array(
'ContentType' => 'HTML',
'Content' => 'Not really concluant...'),
'Start' => "2015-04-22T18:00:00Z",
'End' => "2015-04-22T19:00:00Z",
'StartTimeZone' => 'Europe Standard Time',
'EndTimeZone' => 'Europe Standard Time',
);
var_dump($this->rest->post('events', json_encode($event), 'json'));
以下是回应:
找不到与内容类型匹配的受支持MIME类型
对答复的答复。没有支持的类型
'应用程序/json;元数据=最小值
我做错了什么?请不要全说 我不确定欧洲标准时间是否正确。请从时区列中显示的列表中指定时区。您需要将内容类型标题设置为application/json。我不确定如何使用特定的API实现这一点,但这听起来像是您的问题。我正在寻找相同的解决方案,然后我发现: 您首先需要一个对要创建的日历拥有所有者权限的用户 您可以使用管理员帐户进行测试 然后您需要在base64中编码您的登录密码 去这个网站,你可以在线做 然后选择base64encode 在方框内写下如下示例: 厕所。smith@domain.com:密码 复制结果:示例 am9obi5zbWl0aEBkb21haW4uY29tOnBhc3N3b3Jk 第一步:在php中读取事件:
<?
$mail = "eric.blik@domain.com"; // agenda email you want to check
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Authorization: Basic am9obi5zbWl0aEBkb21haW4uY29tOnBhc3N3b3Jk"
// replace after basic by the password
)
);
$context = stream_context_create($opts);
$ret_event = file_get_contents("https://outlook.office365.com/api/v1.0/users/" . $mail . "/calendarview?startDateTime=2015-06-30T09:00:00Z&endDateTime=2015-06-30T18:00:00Z", false, $context);
echo "<pre>";
print_r(json_decode($ret_event));
echo "</pre>";
?>
第二步:用php编写事件:
<?
$mail = "eric.blik@domain.com"; // agenda email you want to check
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Authorization: Basic am9obi5zbWl0aEBkb21haW4uY29tOnBhc3N3b3Jk"
// replace after basic by the password
)
);
$context = stream_context_create($opts);
$ret_event = file_get_contents("https://outlook.office365.com/api/v1.0/users/" . $mail . "/calendarview?startDateTime=2015-06-30T09:00:00Z&endDateTime=2015-06-30T18:00:00Z", false, $context);
echo "<pre>";
print_r(json_decode($ret_event));
echo "</pre>";
?>
现在检查您的日程,您将有您的活动
您可以添加许多设置,如类别或其他信息
它也适用于电子邮件、Onenote和Sharepoint
等待您的反馈我尝试了其他区域。对我来说,正确的答案是浪漫,但同样的问题是:您能否提供实际的请求和响应,包括标题,不包括授权标题中提供的凭据?